diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/RepairApplyOutRegisterInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/RepairApplyOutRegisterInput.cs
new file mode 100644
index 00000000..22d61759
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/RepairApplyOutRegisterInput.cs
@@ -0,0 +1,42 @@
+namespace Tnb.EquipMgr.Entities.Dto
+{
+ public class RepairApplyOutRegisterInput
+ {
+ public string id { get; set; }
+
+ ///
+ /// 实际维修供应商id
+ ///
+ public string? real_supplier_id { get; set; }
+
+ ///
+ /// 附件
+ ///
+ public string? attachment { get; set; }
+
+ ///
+ /// 费用
+ ///
+ public decimal? cost { get; set; }
+
+ ///
+ /// 修复时间
+ ///
+ public DateTime? repair_time { get; set; }
+
+ ///
+ /// 维修耗时
+ ///
+ public decimal? repair_take_time { get; set; }
+
+ ///
+ /// 维修备注
+ ///
+ public string? repair_remark { get; set; }
+
+ ///
+ /// 报修申请id
+ ///
+ public string repair_apply_id { get; set; }
+ }
+}
\ No newline at end of file
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/EqpRepairApply.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairApply.cs
index 874ef15f..96668b36 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairApply.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairApply.cs
@@ -47,7 +47,7 @@ public partial class EqpRepairApply : BaseEntity
///
/// 设备ID
///
- public string? equip_id { get; set; }
+ public string equip_id { get; set; }
///
/// 申请用户ID
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairOutApply.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairOutApply.cs
index f8aca2cc..adc2cfe6 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairOutApply.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairOutApply.cs
@@ -113,5 +113,27 @@ public partial class EqpRepairOutApply : BaseEntity
/// 所属组织
///
public string? org_id { get; set; }
+
+ ///
+ /// 附件
+ ///
+ public string? attachment { get; set; }
+
+ ///
+ /// 实际维修供应商
+ ///
+ public string? real_supplier_id { get; set; }
+
+ ///
+ /// 流程id
+ ///
+ [SugarColumn(ColumnName = "f_flowid")]
+ public string? flow_id { get; set; }
+
+ ///
+ /// 流程任务id
+ ///
+ [SugarColumn(ColumnName = "f_flowtaskid")]
+ public string? flow_task_id { get; set; }
}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsItem.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsItem.cs
index 086cad89..35deb165 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsItem.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsItem.cs
@@ -82,7 +82,7 @@ public partial class EqpSpotInsItem : BaseEntity
///
/// 单位id
///
- public string unit_id { get; set; } = string.Empty;
+ public string? unit_id { get; set; } = string.Empty;
///
/// 点巡检方法
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/IEqpRepairOutApplyService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairOutApplyService.cs
index 8416d5f7..5e3b57dd 100644
--- a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairOutApplyService.cs
+++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairOutApplyService.cs
@@ -6,11 +6,23 @@ namespace Tnb.EquipMgr.Interfaces
public interface IEqpRepairOutApplyService
{
+ ///
+ /// 获取外修申请信息
+ ///
+ ///
+ public Task GetInfo(Dictionary dic);
+
///
/// 外修申请
///
///
public Task OutApply(RepairOutApplyInput input);
+ ///
+ /// 外修登记
+ ///
+ ///
+ public Task Register(RepairApplyOutRegisterInput 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/EqpRepairOutApplyService.cs b/EquipMgr/Tnb.EquipMgr/EqpRepairOutApplyService.cs
index 02b29e68..0707afa3 100644
--- a/EquipMgr/Tnb.EquipMgr/EqpRepairOutApplyService.cs
+++ b/EquipMgr/Tnb.EquipMgr/EqpRepairOutApplyService.cs
@@ -1,10 +1,13 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
+using JNPF.Common.Models.WorkFlow;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
+using JNPF.WorkFlow.Interfaces.Service;
using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json.Linq;
using SqlSugar;
using Tnb.EquipMgr.Entities;
using Tnb.EquipMgr.Entities.Dto;
@@ -21,36 +24,50 @@ namespace Tnb.EquipMgr
{
private readonly ISqlSugarRepository _repository;
private readonly IUserManager _userManager;
+ private readonly IFlowTaskService _flowTaskService;
+ private const string flowId = "26299060075302";
public EqpRepairOutApplyService(ISqlSugarRepository repository,
+ IFlowTaskService flowTaskService,
IUserManager userManager)
{
_repository = repository;
_userManager = userManager;
+ _flowTaskService = flowTaskService;
}
+ [HttpPost]
+ public async Task GetInfo(Dictionary dic)
+ {
+ string id = dic["id"];
+ EqpRepairApply eqpRepairApply = await _repository.AsSugarClient().Queryable().SingleAsync(x => x.id == id);
+ return await _repository.GetSingleAsync(x => x.repair_apply_id==eqpRepairApply.id);
+ }
+
+ [HttpPost]
public async Task OutApply(RepairOutApplyInput input)
{
var db = _repository.AsSugarClient();
+ string id = string.IsNullOrEmpty(input.id) ? SnowflakeIdHelper.NextId() : input.id;
DbResult result = await db.Ado.UseTranAsync(async () =>
{
if (string.IsNullOrEmpty(input.id))
{
- await _repository.InsertAsync(new EqpRepairOutApply
- {
- id = SnowflakeIdHelper.NextId(),
- repair_apply_id = input.repair_apply_id,
- equip_id = input.equip_id,
- supplier_id = input.supplier_id,
- estimated_cost = input.estimated_cost,
- construction_period_requirement = input.construction_period_requirement,
- out_apply_reason = input.out_apply_reason,
- remark = input.remark,
- create_id = _userManager.UserId,
- create_time = DateTime.Now,
- approve_status = RepairOutApplyStatus.TOBEAPPROVE,
- });
+ // await _repository.InsertAsync(new EqpRepairOutApply
+ // {
+ // id = id,
+ // repair_apply_id = input.repair_apply_id,
+ // equip_id = input.equip_id,
+ // supplier_id = input.supplier_id,
+ // estimated_cost = input.estimated_cost,
+ // construction_period_requirement = input.construction_period_requirement,
+ // out_apply_reason = input.out_apply_reason,
+ // remark = input.remark,
+ // create_id = _userManager.UserId,
+ // create_time = DateTime.Now,
+ // approve_status = RepairOutApplyStatus.TOBEAPPROVE,
+ // });
}
else
{
@@ -73,10 +90,62 @@ namespace Tnb.EquipMgr
.SetColumns(x=>x.status == RepairApplyStatus.OUTAPPLYAPPROVE)
.Where(x=>x.id==input.repair_apply_id).ExecuteCommandAsync();
+
+
});
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
+
+ //todo 退回流程
+ if (result.IsSuccess)
+ {
+ _flowTaskService.Create(new FlowTaskSubmitModel()
+ {
+ flowId = flowId,
+ parentId = "0",
+ formData = new JObject()
+ {
+ {"id",id},
+ {"repair_apply_id",input.repair_apply_id},
+ {"equip_id",input.equip_id},
+ {"create_id",_userManager.UserId},
+ {"supplier_id",input.supplier_id},
+ {"estimated_cost",input.estimated_cost},
+ {"construction_period_requirement",input.construction_period_requirement},
+ {"out_apply_reason",input.out_apply_reason},
+ {"remark",input.remark},
+ {"approve_status",RepairOutApplyStatus.TOBEAPPROVE},
+ }
+
+ });
+ }
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
}
+
+ [HttpPost]
+ public async Task Register(RepairApplyOutRegisterInput input)
+ {
+
+ var db = _repository.AsSugarClient();
+ DbResult result = await db.Ado.UseTranAsync(async () =>
+ {
+ await _repository.UpdateAsync(x => new EqpRepairOutApply()
+ {
+ real_supplier_id = input.real_supplier_id,
+ cost = input.cost,
+ repair_time = input.repair_time,
+ repair_take_time = input.repair_take_time,
+ repair_remark = input.repair_remark,
+ attachment = input.attachment,
+ }, x => x.id == input.id);
+
+ await db.Updateable().SetColumns(x => x.status == RepairApplyStatus.COMPLETED)
+ .Where(x => x.id == input.repair_apply_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/EquSpotInsRecordService.cs b/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs
index d7fc7a2f..cf3a76aa 100644
--- a/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs
+++ b/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs
@@ -121,7 +121,7 @@ namespace Tnb.EquipMgr
{
repeat_result = input.repeat_result,
repeat_remark = input.repeat_remark,
- repeat_post_info_user_id = _userManager.UserId,
+ repeat_user_id = _userManager.UserId,
repeat_time = DateTime.Now,
status = SpotInsRecordExecutionStatus.COMPLETED
}, x => x.id == input.id);
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/apihost/Tnb.API.Entry/Extensions/ConfigureSqlSugarExtensions.cs b/apihost/Tnb.API.Entry/Extensions/ConfigureSqlSugarExtensions.cs
index 667f28ee..3b269846 100644
--- a/apihost/Tnb.API.Entry/Extensions/ConfigureSqlSugarExtensions.cs
+++ b/apihost/Tnb.API.Entry/Extensions/ConfigureSqlSugarExtensions.cs
@@ -13,60 +13,60 @@ namespace Microsoft.Extensions.DependencyInjection;
///
public static class ConfigureSqlSugarExtensions
{
- public static IServiceCollection ConfigureSqlSugar(this IServiceCollection services)
- {
- // 获取选项
- ConnectionStringsOptions conn = App.GetConfig("ConnectionStrings", true);
-
- List connectConfigList = new List();
- var DBType = (DbType)Enum.Parse(typeof(DbType), conn.DBType);
- // 默认数据库
- connectConfigList.Add(new ConnectionConfig
+ public static IServiceCollection ConfigureSqlSugar(this IServiceCollection services)
{
- ConnectionString = string.Format(conn.DefaultConnection, conn.Host, conn.Port, conn.DBName, conn.UserName, conn.Password),
- DbType = DBType,
- IsAutoCloseConnection = true,
- ConfigId = conn.ConfigId,
- InitKeyType = InitKeyType.Attribute,
- MoreSettings = new ConnMoreSettings()
- {
- IsAutoRemoveDataCache = true // 自动清理缓存
- },
- });
+ // 获取选项
+ ConnectionStringsOptions conn = App.GetConfig("ConnectionStrings", true);
- services.AddSqlSugar(connectConfigList, client =>
- {
- //connectConfigList.ForEach(config =>
- //{
- // var db = ((SqlSugarScope)client).GetConnectionScope((string)config.ConfigId);
+ List connectConfigList = new List();
+ var DBType = (DbType)Enum.Parse(typeof(DbType), conn.DBType);
+ // 默认数据库
+ connectConfigList.Add(new ConnectionConfig
+ {
+ ConnectionString = string.Format(conn.DefaultConnection, conn.Host, conn.Port, conn.DBName, conn.UserName, conn.Password),
+ DbType = DBType,
+ IsAutoCloseConnection = true,
+ ConfigId = conn.ConfigId,
+ InitKeyType = InitKeyType.Attribute,
+ MoreSettings = new ConnMoreSettings()
+ {
+ IsAutoRemoveDataCache = true // 自动清理缓存
+ },
+ });
- // // 设置超时时间
- // db.Ado.CommandTimeOut = 30;
- // db.Aop.OnLogExecuted = (sql, pars) =>
- // {
- // var oldColor = Console.ForegroundColor;
- // Console.ForegroundColor = ConsoleColor.Green;
- // var finalSql = UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, sql, pars);
- // Console.WriteLine($"【{DateTime.Now.ToString("HH:mm:ss.fff")}——SQL执行完成】{db.Ado.SqlExecutionTime.TotalMilliseconds} ms");
- // Console.WriteLine(finalSql);
- // Console.ForegroundColor = oldColor;
- // if (db.Ado.SqlExecutionTime.TotalMilliseconds > 3000)
- // {
- // Log.Warning($"慢查询: {db.Ado.SqlExecutionTime.TotalMilliseconds}ms, SQL: " + finalSql);
- // }
- // Console.WriteLine();
- // };
- // db.Aop.OnError = (ex) =>
- // {
- // Log.Error(UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, ex.Sql, (SugarParameter[])ex.Parametres));
- // };
- //});
- });
- services.AddConfigurableOptions();
- services.AddConfigurableOptions();
- services.AddUnitOfWork();
+ services.AddSqlSugar(connectConfigList, client =>
+ {
+ connectConfigList.ForEach(config =>
+ {
+ var db = ((SqlSugarScope)client).GetConnectionScope((string)config.ConfigId);
+
+ // 设置超时时间
+ db.Ado.CommandTimeOut = 30;
+ //db.Aop.OnLogExecuted = (sql, pars) =>
+ //{
+ // var oldColor = Console.ForegroundColor;
+ // Console.ForegroundColor = ConsoleColor.Green;
+ // var finalSql = UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, sql, pars);
+ // Console.WriteLine($"【{DateTime.Now.ToString("HH:mm:ss.fff")}——SQL执行完成】{db.Ado.SqlExecutionTime.TotalMilliseconds} ms");
+ // Console.WriteLine(finalSql);
+ // Console.ForegroundColor = oldColor;
+ // if (db.Ado.SqlExecutionTime.TotalMilliseconds > 3000)
+ // {
+ // Log.Warning($"慢查询: {db.Ado.SqlExecutionTime.TotalMilliseconds}ms, SQL: " + finalSql);
+ // }
+ // Console.WriteLine();
+ //};
+ //db.Aop.OnError = (ex) =>
+ //{
+ // Log.Error(UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, ex.Sql, (SugarParameter[])ex.Parametres));
+ //};
+ });
+ });
+ services.AddConfigurableOptions();
+ services.AddConfigurableOptions();
+ services.AddUnitOfWork();
- return services;
- }
+ return services;
+ }
}
\ No newline at end of file
diff --git a/common/Tnb.Common.Core/Manager/User/UserManager.cs b/common/Tnb.Common.Core/Manager/User/UserManager.cs
index 9f19adae..0d8f67ac 100644
--- a/common/Tnb.Common.Core/Manager/User/UserManager.cs
+++ b/common/Tnb.Common.Core/Manager/User/UserManager.cs
@@ -193,7 +193,18 @@ public class UserManager : IUserManager, IScoped
///
public string UserOrigin
{
- get => _httpContext?.Request.Headers["jnpf-origin"];
+ //modifyby zhoukeda 调用发起工作流接口取不到pc还是app 改成默认pc
+ get
+ {
+ try
+ {
+ return _httpContext?.Request.Headers["jnpf-origin"] ?? "pc";
+ }
+ catch (Exception e)
+ {
+ return "pc";
+ }
+ }
}
///
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("----------------------开始生成点巡检计划----------------------");
diff --git a/workflow/Tnb.WorkFlow/Service/FlowTaskService.cs b/workflow/Tnb.WorkFlow/Service/FlowTaskService.cs
index 262df2ba..ce7fdec1 100644
--- a/workflow/Tnb.WorkFlow/Service/FlowTaskService.cs
+++ b/workflow/Tnb.WorkFlow/Service/FlowTaskService.cs
@@ -6,6 +6,7 @@ using JNPF.FriendlyException;
using JNPF.WorkFlow.Entitys.Model;
using JNPF.WorkFlow.Interfaces.Manager;
using JNPF.WorkFlow.Interfaces.Service;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace JNPF.WorkFlow.Service;