From 991f6618ee8dcd1bfd6c59a039db13a69dcf43ad Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Wed, 24 May 2023 17:24:05 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=BF=9D=E5=85=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Entity/EqpMaintainItem.cs | 85 +--------
.../Entity/EqpMaintainRecordD.cs | 92 ++++++++++
.../Entity/EqpMaintainRecordH.cs | 167 ++++++++++++++++++
.../Entity/EqpMaintainTemD.cs | 27 +++
.../Entity/EqpMaintainTemEquipD.cs | 27 +++
.../Entity/EqpMaintainTemEquipH.cs | 137 ++++++++++++++
.../Entity/EqpMaintainTemH.cs | 132 ++++++++++++++
.../Entity/EqpSpotInsRecordD.cs | 7 +-
.../IEqpMaintainTemEquipService.cs | 13 ++
.../IEqpMaintainTemService.cs | 12 ++
.../IEquSpotInsTemEquipService.cs | 7 -
.../EqpMaintainTemEquipService.cs | 52 ++++++
.../Tnb.EquipMgr/EqpMaintainTemService.cs | 119 +++++++++++++
.../Tnb.EquipMgr/EquSpotInsTemEquipService.cs | 23 +--
.../GenerateMaintainPlanTimeWorker.cs | 153 ++++++++++++++++
.../GenerateSpotInspectionPlanTimeWorker.cs | 2 +-
16 files changed, 945 insertions(+), 110 deletions(-)
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordD.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordH.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemD.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipD.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipH.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemH.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemEquipService.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemService.cs
create mode 100644 EquipMgr/Tnb.EquipMgr/EqpMaintainTemEquipService.cs
create mode 100644 EquipMgr/Tnb.EquipMgr/EqpMaintainTemService.cs
create mode 100644 taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainItem.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainItem.cs
index 1c6c27be..754685cf 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainItem.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainItem.cs
@@ -5,7 +5,7 @@ using SqlSugar;
namespace Tnb.EquipMgr.Entities;
///
-/// 保养项目
+/// 设备保养项目
///
[SugarTable("eqp_maintain_item")]
public partial class EqpMaintainItem : BaseEntity
@@ -34,25 +34,20 @@ public partial class EqpMaintainItem : BaseEntity
///
public string? modify_id { get; set; }
- ///
- /// 设备类型
- ///
- public string? equip_type_id { get; set; }
-
///
/// 项目编码
///
- public string? item_code { get; set; }
+ public string? code { get; set; }
///
/// 项目名称
///
- public string? item_name { get; set; }
+ public string? name { get; set; }
///
/// 保养类型
///
- public int? maintain_type { get; set; }
+ public string maintain_type { get; set; }
///
/// 保养内容
@@ -74,79 +69,9 @@ public partial class EqpMaintainItem : BaseEntity
///
public int? ordinal { get; set; }
- ///
- /// 是否启用
- ///
- public int? enabled { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend01 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend02 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend03 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend04 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend05 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend06 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend07 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend08 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend09 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend10 { get; set; }
-
- ///
- /// 删除用户
- ///
- public string? delete_id { get; set; }
-
- ///
- /// 删除时间
- ///
- public DateTime? delete_time { get; set; }
-
- ///
- /// 删除标志
- ///
- public short? deleted { get; set; }
-
///
/// 所属组织
///
public string? org_id { get; set; }
-}
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordD.cs
new file mode 100644
index 00000000..215c962a
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordD.cs
@@ -0,0 +1,92 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.EquipMgr.Entities;
+
+///
+/// 设备保养执行记录子表
+///
+[SugarTable("eqp_maintain_record_d")]
+public partial class EqpMaintainRecordD : BaseEntity
+{
+ public EqpMaintainRecordD()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 设备保养执行记录id
+ ///
+ public string maintain_record_id { get; set; } = string.Empty;
+
+ ///
+ /// 设备保养检项id
+ ///
+ public string maintain_item_id { get; set; } = string.Empty;
+
+ ///
+ /// 编码
+ ///
+ public string? code { get; set; }
+
+ ///
+ /// 名称
+ ///
+ public string? name { get; set; }
+
+ ///
+ /// 结果 1 通过 2 不通过
+ ///
+ public string? result { get; set; }
+
+ ///
+ /// 备注
+ ///
+ public string? remark { get; set; }
+
+ ///
+ /// 排序
+ ///
+ public long ordinal { get; set; }
+
+ ///
+ /// 设备保养设备模板id
+ ///
+ public string? maintain_tem_equip_id { get; set; }
+
+ ///
+ /// 是否通过
+ ///
+ public string? is_pass { get; set; }
+
+ ///
+ /// 保养项描述
+ ///
+ public string? descrip { get; set; }
+
+ ///
+ /// 保养类型
+ ///
+ public string maintain_type { get; set; } = string.Empty;
+
+ ///
+ /// 保养内容
+ ///
+ public string? maintain_content { get; set; }
+
+ ///
+ /// 保养结果描述
+ ///
+ public string? maintain_descrip { get; set; }
+
+ ///
+ /// 复核 1 通过 2 不通过
+ ///
+ public string? repeat_result { get; set; }
+
+ ///
+ /// 复核结果描述
+ ///
+ public string? repeat_descrip { get; set; }
+
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordH.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordH.cs
new file mode 100644
index 00000000..0b5aebc5
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordH.cs
@@ -0,0 +1,167 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.EquipMgr.Entities;
+
+///
+/// 设备保养执行记录主表
+///
+[SugarTable("eqp_maintain_record_h")]
+public partial class EqpMaintainRecordH : BaseEntity
+{
+ public EqpMaintainRecordH()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 设备id
+ ///
+ public string equip_id { get; set; } = string.Empty;
+
+ ///
+ /// 设备保养设备模板id
+ ///
+ public string maintain_tem_equip_id { get; set; } = string.Empty;
+
+ ///
+ /// 结果1 合格2不合格
+ ///
+ public string? result { get; set; }
+
+ ///
+ /// 点巡检结果备注
+ ///
+ public string? result_remark { get; set; }
+
+ ///
+ /// 执行时间
+ ///
+ public DateTime? execute_time { get; set; }
+
+ ///
+ /// 状态 1待执行 2 待复核 3 已完成
+ ///
+ public string? status { get; set; }
+
+ ///
+ /// 执行人id
+ ///
+ public string? execute_user_id { get; set; }
+
+ ///
+ /// 设备类型id
+ ///
+ public string? equip_type_id { get; set; }
+
+ ///
+ /// 不合格推送
+ ///
+ public int? is_send { get; set; }
+
+ ///
+ /// 推送时间
+ ///
+ public DateTime? send_date_time { get; set; }
+
+ ///
+ /// 推送人id
+ ///
+ public string? send_id { get; set; }
+
+ ///
+ /// 编码
+ ///
+ public string? code { get; set; }
+
+ ///
+ /// 计划执行通知提前量
+ ///
+ public int? plan_run_notice { get; set; }
+
+ ///
+ /// 计划执行通知提前量单位 1 小时 2 天 3 周
+ ///
+ public string? plan_run_notice_unit { get; set; }
+
+ ///
+ /// 执行滞后推送时间
+ ///
+ public int? plan_delay { get; set; }
+
+ ///
+ /// 执行滞后推送时间单位 1 小时 2 天 3 周
+ ///
+ public string? plan_delay_unit { get; set; }
+
+ ///
+ /// 复核岗位id
+ ///
+ public string? repeat_post_info_user_id { get; set; }
+
+ ///
+ /// 责任岗位id
+ ///
+ public string? send_post_info_user_id { get; set; }
+
+ ///
+ /// 是否复核
+ ///
+ public string? is_repeat { get; set; }
+
+ ///
+ /// 复核时间
+ ///
+ public DateTime? repeat_time { get; set; }
+
+ ///
+ /// 复核备注
+ ///
+ public string? repeat_remark { get; set; }
+
+ ///
+ /// 复核人id
+ ///
+ public string? repeat_user_id { get; set; }
+
+ ///
+ /// 仅用于关联表字段查询用不存储数据
+ ///
+ public string? query_info { get; set; }
+
+ ///
+ /// 附件
+ ///
+ public string? attachment { get; set; }
+
+ ///
+ /// 复核结果
+ ///
+ public string? repeat_result { get; set; }
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemD.cs
new file mode 100644
index 00000000..b33f7c47
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemD.cs
@@ -0,0 +1,27 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.EquipMgr.Entities;
+
+///
+/// 设备保养模板子表
+///
+[SugarTable("eqp_maintain_tem_d")]
+public partial class EqpMaintainTemD : BaseEntity
+{
+ public EqpMaintainTemD()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 设备保养模板主表id
+ ///
+ public string maintain_tem_id { get; set; } = string.Empty;
+
+ ///
+ /// 设备保养项id
+ ///
+ public string maintain_item_id { get; set; } = string.Empty;
+
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipD.cs
new file mode 100644
index 00000000..7f5cf251
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipD.cs
@@ -0,0 +1,27 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.EquipMgr.Entities;
+
+///
+/// 设备保养设备模板子表
+///
+[SugarTable("eqp_maintain_tem_equip_d")]
+public partial class EqpMaintainTemEquipD : BaseEntity
+{
+ public EqpMaintainTemEquipD()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 设备保养设备模板主表id
+ ///
+ public string maintain_tem_equip_id { get; set; } = string.Empty;
+
+ ///
+ /// 设备保养项id
+ ///
+ public string maintain_item_id { get; set; } = string.Empty;
+
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipH.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipH.cs
new file mode 100644
index 00000000..27755b9c
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipH.cs
@@ -0,0 +1,137 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.EquipMgr.Entities;
+
+///
+/// 设备保养设备模板主表
+///
+[SugarTable("eqp_maintain_tem_equip_h")]
+public partial class EqpMaintainTemEquipH : BaseEntity
+{
+ public EqpMaintainTemEquipH()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 创建时间
+ ///
+ public DateTime create_time { get; set; } = DateTime.Now;
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 设备保养模板表id
+ ///
+ public string? maintain_tem_id { get; set; }
+
+ ///
+ /// 设备id
+ ///
+ public string? equip_id { get; set; }
+
+ ///
+ /// 备注
+ ///
+ public string? remark { get; set; }
+
+ ///
+ /// 排序
+ ///
+ public int ordinal { get; set; }
+
+ ///
+ /// 编码
+ ///
+ public string code { get; set; } = string.Empty;
+
+ ///
+ /// 名称
+ ///
+ public string name { get; set; } = string.Empty;
+
+ ///
+ /// 周期
+ ///
+ public int plan_cycle { get; set; }
+
+ ///
+ /// 周期方式 1 单次 2 循环
+ ///
+ public string? plan_cycle_unit { get; set; }
+
+ ///
+ /// 计划执行通知提前量
+ ///
+ public int? plan_run_notice { get; set; }
+
+ ///
+ /// 计划执行通知提前量单位 1 小时 2 天 3 周
+ ///
+ public string? plan_run_notice_unit { get; set; }
+
+ ///
+ /// 执行滞后推送时间
+ ///
+ public int? plan_delay { get; set; }
+
+ ///
+ /// 执行滞后推送时间单位 1 小时 2 天 3 周
+ ///
+ public string? plan_delay_unit { get; set; }
+
+ ///
+ /// 启用时间
+ ///
+ public DateTime start_time { get; set; } = DateTime.Now;
+
+ ///
+ /// 是否启用
+ ///
+ public string is_start { get; set; }
+
+ ///
+ /// 是否复核
+ ///
+ public string is_repeat { get; set; }
+
+ ///
+ /// 复核岗位id
+ ///
+ public string repeat_post_info_user_id { get; set; } = string.Empty;
+
+ ///
+ /// 不合格推送 0 不推送 1 推送
+ ///
+ public int is_send { get; set; }
+
+ ///
+ /// 推送人id
+ ///
+ public string? send_post_id { get; set; }
+
+ ///
+ /// 责任岗位id
+ ///
+ public string send_post_info_user_id { get; set; } = string.Empty;
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemH.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemH.cs
new file mode 100644
index 00000000..a666bf62
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemH.cs
@@ -0,0 +1,132 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.EquipMgr.Entities;
+
+///
+/// 设备保养模板主表
+///
+[SugarTable("eqp_maintain_tem_h")]
+public partial class EqpMaintainTemH : BaseEntity
+{
+ public EqpMaintainTemH()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 设备类型id
+ ///
+ public string? equip_type_id { get; set; }
+
+ ///
+ /// 编码
+ ///
+ public string code { get; set; } = string.Empty;
+
+ ///
+ /// 名称
+ ///
+ public string name { get; set; } = string.Empty;
+
+ ///
+ /// 周期
+ ///
+ public int plan_cycle { get; set; }
+
+ ///
+ /// 周期方式 1 单次 2 循环
+ ///
+ public string plan_cycle_unit { get; set; }
+
+ ///
+ /// 计划执行通知提前量
+ ///
+ public int? plan_run_notice { get; set; }
+
+ ///
+ /// 计划执行通知提前量单位 1 小时 2 天 3 周
+ ///
+ public string? plan_run_notice_unit { get; set; }
+
+ ///
+ /// 执行滞后推送时间
+ ///
+ public int? plan_delay { get; set; }
+
+ ///
+ /// 执行滞后推送时间单位 1 小时 2 天 3 周
+ ///
+ public string? plan_delay_unit { get; set; }
+
+ ///
+ /// 启用时间
+ ///
+ public DateTime start_time { get; set; } = DateTime.Now;
+
+ ///
+ /// 是否启用
+ ///
+ public int is_start { get; set; }
+
+ ///
+ /// 是否复核
+ ///
+ public int is_repeat { get; set; }
+
+ ///
+ /// 复核岗位id
+ ///
+ public string repeat_post_info_user_id { get; set; } = string.Empty;
+
+ ///
+ /// 备注
+ ///
+ public string? remark { get; set; }
+
+ ///
+ /// 排序
+ ///
+ public int? ordinal { get; set; }
+
+ ///
+ /// 不合格推送 0 不推送 1 推送
+ ///
+ public int is_send { get; set; }
+
+ ///
+ /// 推送人id
+ ///
+ public string? send_post_id { get; set; }
+
+ ///
+ /// 责任岗位id
+ ///
+ public string send_post_info_user_id { get; set; } = string.Empty;
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs
index 2de21636..61c0ae8c 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs
@@ -72,7 +72,7 @@ public partial class EqpSpotInsRecordD : BaseEntity
///
/// 单位id
///
- public string unit_id { get; set; } = string.Empty;
+ public string? unit_id { get; set; } = string.Empty;
///
/// 点巡检方法
@@ -108,5 +108,10 @@ public partial class EqpSpotInsRecordD : BaseEntity
/// 是否通过
///
public string? is_pass { get; set; }
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
}
diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemEquipService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemEquipService.cs
new file mode 100644
index 00000000..1b6496a5
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemEquipService.cs
@@ -0,0 +1,13 @@
+namespace Tnb.EquipMgr.Interfaces
+{
+ public interface IEqpMaintainTemEquipService
+ {
+
+ ///
+ /// 停止计划
+ ///
+ ///
+ ///
+ public Task Stop(Dictionary parameters);
+ }
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemService.cs
new file mode 100644
index 00000000..59962bce
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemService.cs
@@ -0,0 +1,12 @@
+using Tnb.EquipMgr.Entities.Dto;
+namespace Tnb.EquipMgr.Interfaces
+{
+ public interface IEqpMaintainTemService
+ {
+ ///
+ /// 根据模板id发布到设备
+ ///
+ ///
+ public Task Publish(SpotInsTemPublishInput input);
+ }
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsTemEquipService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsTemEquipService.cs
index 48b4b400..38790883 100644
--- a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsTemEquipService.cs
+++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsTemEquipService.cs
@@ -2,13 +2,6 @@ namespace Tnb.EquipMgr.Interfaces
{
public interface IEquSpotInsTemEquipService
{
- // ///
- // /// 获取数
- // ///
- // ///
- // ///
- // public Task GetTree();
-
///
/// 停止计划
///
diff --git a/EquipMgr/Tnb.EquipMgr/EqpMaintainTemEquipService.cs b/EquipMgr/Tnb.EquipMgr/EqpMaintainTemEquipService.cs
new file mode 100644
index 00000000..fc9f254a
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr/EqpMaintainTemEquipService.cs
@@ -0,0 +1,52 @@
+using JNPF.Common.Enums;
+using JNPF.Common.Security;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using JNPF.FriendlyException;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+using Tnb.EquipMgr.Interfaces;
+using Tnb.EquipMgr.Entities;
+
+namespace Tnb.EquipMgr
+{
+ ///
+ /// 设备保养设备模板
+ ///
+ [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
+ [Route("api/[area]/[controller]/[action]")]
+ public class EqpMaintainTemEquipService : IEqpMaintainTemEquipService, IDynamicApiController, ITransient
+ {
+ private readonly ISqlSugarRepository _repository;
+
+ public EqpMaintainTemEquipService(ISqlSugarRepository repository)
+ {
+ _repository = repository;
+ }
+
+
+ [HttpPost]
+ public async Task Stop(Dictionary parameters)
+ {
+ string id = parameters["id"];
+ DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
+ {
+ await _repository.UpdateAsync(x => new EqpMaintainTemEquipH()
+ {
+ is_start = "0"
+ }, x => x.id == id);
+ List ids = await _repository.AsSugarClient().Queryable()
+ .Where(x => x.maintain_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED)
+ .Select(x => x.id).ToListAsync();
+ await _repository.AsSugarClient().Deleteable()
+ .Where(x => x.maintain_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED).ExecuteCommandAsync();
+
+ await _repository.AsSugarClient().Deleteable()
+ .Where(x => ids.Contains(x.maintain_record_id)).ExecuteCommandAsync();
+
+ });
+
+ if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
+ }
+ }
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr/EqpMaintainTemService.cs b/EquipMgr/Tnb.EquipMgr/EqpMaintainTemService.cs
new file mode 100644
index 00000000..bc1bc84f
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr/EqpMaintainTemService.cs
@@ -0,0 +1,119 @@
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Enums;
+using JNPF.Common.Security;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using JNPF.FriendlyException;
+using Microsoft.AspNetCore.Mvc;
+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 EqpMaintainTemService : IEqpMaintainTemService, IDynamicApiController, ITransient
+ {
+ private const string ModuleId = "26123080740885";
+ private readonly ISqlSugarRepository _repository;
+ private readonly IUserManager _userManager;
+
+ public EqpMaintainTemService(ISqlSugarRepository repository,
+ IUserManager userManager)
+ {
+ _repository = repository;
+ _userManager = userManager;
+ }
+
+ ///
+ /// 根据模板id发布到设备
+ ///
+ ///
+ [HttpPost]
+ public async Task Publish(SpotInsTemPublishInput input)
+ {
+ var db = _repository.AsSugarClient();
+ DbResult result = await db.Ado.UseTranAsync(async () =>
+ {
+ EqpMaintainTemH eqpMaintainTemH = await _repository.GetSingleAsync(x => x.id == input.id);
+ List eqpMaintainTemDs = await db.Queryable().Where(x=>x.maintain_tem_id==input.id).ToListAsync();
+
+ if (input.equipIds != null && input.equipIds.Length > 0)
+ {
+ List insertEqpMaintainTemEquipHs = new List();
+ List insertEqpMaintainTemEquipDs = new List();
+ foreach (var equipId in input.equipIds)
+ {
+ string id = SnowflakeIdHelper.NextId();
+ string code = $"{DateTime.Now.ToString("yyyyMMdd") + equipId}";
+ EqpMaintainTemEquipH eqpMaintainTemEquipH = new EqpMaintainTemEquipH()
+ {
+ id = id,
+ code = code,
+ name = eqpMaintainTemH.name+equipId,
+ plan_cycle = eqpMaintainTemH.plan_cycle,
+ plan_cycle_unit = eqpMaintainTemH.plan_cycle_unit,
+ plan_run_notice = eqpMaintainTemH.plan_run_notice,
+ plan_delay = eqpMaintainTemH.plan_delay,
+ start_time = eqpMaintainTemH.start_time,
+ is_start = eqpMaintainTemH.is_start.ToString(),
+ is_repeat = eqpMaintainTemH.is_repeat.ToString(),
+ is_send = eqpMaintainTemH.is_send,
+ maintain_tem_id = input.id,
+ equip_id = equipId,
+ remark = eqpMaintainTemH.remark,
+ plan_run_notice_unit = eqpMaintainTemH.plan_run_notice_unit,
+ plan_delay_unit = eqpMaintainTemH.plan_delay_unit,
+ repeat_post_info_user_id = eqpMaintainTemH.repeat_post_info_user_id,
+ send_post_info_user_id = eqpMaintainTemH.send_post_info_user_id,
+ send_post_id = eqpMaintainTemH.send_post_id,
+ org_id = eqpMaintainTemH.org_id,
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now,
+ };
+ insertEqpMaintainTemEquipHs.Add(eqpMaintainTemEquipH);
+
+ if (eqpMaintainTemDs != null && eqpMaintainTemDs.Count > 0)
+ {
+ foreach (var eqpMaintainTem in eqpMaintainTemDs)
+ {
+ EqpMaintainTemEquipD eqpMaintainTemEquipD = new EqpMaintainTemEquipD()
+ {
+ id = SnowflakeIdHelper.NextId(),
+ maintain_item_id = eqpMaintainTem.maintain_item_id,
+ maintain_tem_equip_id = id,
+ };
+ insertEqpMaintainTemEquipDs.Add(eqpMaintainTemEquipD);
+ }
+ }
+
+ EqpMaintainTemEquipH oldMaintainTemEquipH = await db.Queryable().Where(x => x.maintain_tem_id == input.id && x.equip_id == equipId).FirstAsync();
+ await db.Deleteable().Where(x => x.maintain_tem_id == input.id && x.equip_id==equipId).ExecuteCommandAsync();
+ if(oldMaintainTemEquipH!=null)
+ await db.Deleteable().Where(x => x.maintain_tem_equip_id==oldMaintainTemEquipH.id).ExecuteCommandAsync();
+ }
+
+ if (insertEqpMaintainTemEquipHs != null && insertEqpMaintainTemEquipHs.Count > 0)
+ {
+ await db.Insertable(insertEqpMaintainTemEquipHs).ExecuteCommandAsync();
+ }
+
+ if (insertEqpMaintainTemEquipDs != null && insertEqpMaintainTemEquipDs.Count > 0)
+ {
+ await db.Insertable(insertEqpMaintainTemEquipDs).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/EquSpotInsTemEquipService.cs b/EquipMgr/Tnb.EquipMgr/EquSpotInsTemEquipService.cs
index f866e77c..b4ff4caa 100644
--- a/EquipMgr/Tnb.EquipMgr/EquSpotInsTemEquipService.cs
+++ b/EquipMgr/Tnb.EquipMgr/EquSpotInsTemEquipService.cs
@@ -11,7 +11,7 @@ using Tnb.EquipMgr.Entities;
namespace Tnb.EquipMgr
{
///
- /// 设备管理
+ /// 点巡检设备模板
///
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
@@ -24,26 +24,7 @@ namespace Tnb.EquipMgr
_repository = repository;
}
- // public async Task GetTree()
- // {
- // List eqpEquipments =
- // var data = _repository.AsSugarClient().Queryable()
- // .Where(x => x.status == 1)
- // .Select((x) => new TreeModel
- // {
- // id = x.id,
- // parentId = "-1",
- // hasChildren = SqlFunc.Subqueryable().Where(y=>y.eqp_type_id==x.id).Any(),
- // isLeaf = false,
- // num = SqlFunc.Subqueryable().Where(y=>y.eqp_type_id==x.id).Count(),
- // children = SqlFunc.Subqueryable().Where(y=>y.eqp_type_id==x.id).Select(y=>new TreeModel()
- // {
- //
- // }).ToList(model => ),
- // });
- // return new { list = 1 };
- // }
-
+ [HttpPost]
public async Task Stop(Dictionary parameters)
{
string id = parameters["id"];
diff --git a/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs b/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs
new file mode 100644
index 00000000..2226d6eb
--- /dev/null
+++ b/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs
@@ -0,0 +1,153 @@
+using JNPF.Common.Security;
+using JNPF.Logging;
+using Microsoft.AspNetCore.Components;
+using SqlSugar;
+using Tnb.EquipMgr.Entities;
+
+namespace JNPF.TaskScheduler.Listener
+{
+ ///
+ /// 生成设备保养计划
+ ///
+ public class GenerateMaintainPlanTimeWorker : ISpareTimeWorker
+ {
+ private ISqlSugarRepository _repository => App.GetService>();
+ // public GenerateSpotInspectionPlanTimeWorker(ISqlSugarRepository repository)
+ // {
+ // _repository = repository;
+ // }
+
+ [SpareTime("0 0 0 * * ?", "生成设备保养计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
+ public void GenerateSpotInspectionPlan(SpareTimer timer, long count)
+ {
+ Log.Information("----------------------开始生成设备保养计划----------------------");
+
+ try
+ {
+ List eqpSpotInsTemEquipHsByOne = _repository.GetList(x => x.is_start=="1" && x.plan_cycle_unit == "1");
+ List eqpSpotInsTemEquipHsByCirculate = _repository.GetList(x => x.is_start=="1" && x.plan_cycle_unit == "2");
+ List tobeCreateList = new List();
+ List tobeCreateTemplets = new List();
+ var db = _repository.AsSugarClient();
+
+ foreach (var item in eqpSpotInsTemEquipHsByOne)
+ {
+ if (item.start_time.AddHours((double)item.plan_cycle).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
+ {
+ tobeCreateTemplets.Add(item);
+ }
+ }
+
+ if (eqpSpotInsTemEquipHsByCirculate != null && eqpSpotInsTemEquipHsByCirculate.Count > 0)
+ {
+
+ //整除表示一个周期到了
+ foreach (var item in eqpSpotInsTemEquipHsByCirculate)
+ {
+ TimeSpan ts1 = new TimeSpan(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")).Ticks);
+ TimeSpan ts2 = new TimeSpan(Convert.ToDateTime(item.start_time.ToString("yyyy-MM-dd")).Ticks);
+ TimeSpan ts3 = ts1.Subtract(ts2).Duration();
+ if (ts3.TotalDays * 10 % (10 * (double)item.plan_cycle)==0)
+ {
+ tobeCreateTemplets.Add(item);
+ }
+ }
+ }
+
+ if (tobeCreateTemplets != null && tobeCreateTemplets.Count > 0)
+ {
+ List equipments = db.Queryable().Where(x => x.life==Tnb.EquipMgr.EquipmentLife.ENABLE).ToList();
+ int index = 1;
+ foreach (var item in tobeCreateTemplets)
+ {
+ //只有启用设备才生成计划
+ if (equipments.FirstOrDefault(x => x.id == item.equip_id) == null)
+ continue;
+
+ string code = $"{DateTime.Now.ToString("yyyyMMdd")+(index++).ToString().PadLeft(3,'0')}";
+ tobeCreateList.Add(new EqpMaintainRecordH()
+ {
+ id = SnowflakeIdHelper.NextId(),
+ code = code,
+ // equip_type_id = item.equip_type_id,
+ equip_id = item.equip_id,
+ maintain_tem_equip_id = item.id,
+ plan_run_notice = item.plan_run_notice,
+ plan_run_notice_unit = item.plan_run_notice_unit,
+ plan_delay = item.plan_delay,
+ plan_delay_unit = item.plan_delay_unit,
+ send_post_info_user_id = item.send_post_info_user_id,
+ is_repeat = item.is_repeat,
+ 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
+ });
+ }
+ }
+
+
+ if (tobeCreateList != null && tobeCreateList.Count > 0)
+ {
+ List templetIDs = tobeCreateList.Select(x => x.maintain_tem_equip_id).ToList();
+ List spotInsTemEquipDs = db.Queryable().Where(x => templetIDs.Contains(x.maintain_tem_equip_id)).ToList();
+ List spotInsItemIDs = spotInsTemEquipDs.Select(x => x.maintain_item_id).ToList();
+ List spotCheckItems = db.Queryable().Where(x => spotInsItemIDs.Contains(x.id)).ToList();
+
+
+ foreach (var tobeCreatePlan in tobeCreateList)
+ {
+ List spotInsRecordDs = new List();
+ List spotInsItems = spotInsTemEquipDs
+ .Where(x => x.maintain_tem_equip_id == tobeCreatePlan.maintain_tem_equip_id)
+ .Select(x => x.maintain_item_id).ToList();
+ List tobeCreateItems = spotCheckItems.Where(x => spotInsItems.Contains(x.id)).ToList();
+ foreach (var tobeCreateItem in tobeCreateItems)
+ {
+ spotInsRecordDs.Add(new EqpMaintainRecordD()
+ {
+ id = SnowflakeIdHelper.NextId(),
+ maintain_record_id = tobeCreatePlan.id,
+ maintain_tem_equip_id = tobeCreatePlan.maintain_tem_equip_id,
+ maintain_item_id = tobeCreateItem.id,
+ code = tobeCreateItem.code,
+ name = tobeCreateItem.name,
+ maintain_type = tobeCreateItem.maintain_type,
+ maintain_content = tobeCreateItem.maintain_content,
+ descrip = tobeCreateItem.descrip,
+ remark = tobeCreateItem.remark
+ });
+ }
+
+ var dbResult = db.Ado.UseTran(() =>
+ {
+ if (tobeCreateList != null && tobeCreateList.Count > 0)
+ {
+ db.Insertable(tobeCreateList).ExecuteCommand();
+ }
+
+ if (spotInsRecordDs != null && spotInsRecordDs.Count > 0)
+ {
+ db.Insertable(spotInsRecordDs).ExecuteCommand();
+ }
+ });
+ if (!dbResult.IsSuccess)
+ {
+ Console.WriteLine(dbResult.ErrorMessage);
+ Log.Error(dbResult.ErrorMessage);
+ }
+ Log.Information($"---------------生成{tobeCreateList.Count}个计划---------------");
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ Log.Error(e.Message);
+ }
+
+
+ Log.Information("----------------------结束生成设备保养计划----------------------");
+ }
+ }
+}
\ No newline at end of file
diff --git a/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs
index 80e723b7..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,30 * * * ?", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
+ [SpareTime("0 0,30 * * * ?", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
public void GenerateSpotInspectionPlan(SpareTimer timer, long count)
{
Log.Information("----------------------开始生成点巡检计划----------------------");