From f6da16904d7dd5c56bcdbd52d2df716127c6025a Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 1 Aug 2024 10:11:23 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=86=99=E6=A8=A1=E5=85=B7=E4=BF=9D?= =?UTF-8?q?=E5=85=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/EquipMaintainRecordQueryOutput.cs | 4 + .../Dto/EquipQueryInput.cs | 2 + .../Dto/ToolMoldMaintainPlanRunListOutput.cs | 17 + .../Dto/ToolMoldMaintainRecordListOutput.cs | 27 ++ .../Dto/ToolMoldMaintainRecordRepeatOutput.cs | 9 + .../Dto/ToolTemPublishInput.cs | 9 + .../Entity/ToolMaintainItem.cs | 77 +++++ .../Entity/ToolMaintainTemD.cs | 27 ++ .../Entity/ToolMaintainTemH.cs | 135 ++++++++ .../Entity/ToolMaintainTemMoldD.cs | 27 ++ .../Entity/ToolMaintainTemMoldH.cs | 140 ++++++++ .../Entity/ToolMoldMaintainPlan.cs | 15 + .../Entity/ToolMoldMaintainRecordD.cs | 92 ++++++ .../Entity/ToolMoldMaintainRecordH.cs | 172 ++++++++++ .../Tnb.EquipMgr/EquMaintainRecordService.cs | 10 +- .../Tnb.EquipMgr/ToolMaintainTemService.cs | 148 +++++++++ .../ToolMoldMaintainRecordService.cs | 304 ++++++++++++++++++ .../ToolMoldMaintainRuleService.cs | 1 + .../ToolMoldMaintainRunService.cs | 71 +++- .../Tnb.WarehouseMgr/WmsPurchaseService.cs | 13 +- .../GenerateMaintainPlanTimeWorker.cs | 268 +++++++++++++-- .../GenerateSpEquipCheckPlanTimeWorker.cs | 7 +- .../GenerateSpotInspectionPlanTimeWorker.cs | 7 +- 23 files changed, 1532 insertions(+), 50 deletions(-) create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldMaintainPlanRunListOutput.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldMaintainRecordListOutput.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldMaintainRecordRepeatOutput.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolTemPublishInput.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainItem.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemD.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemH.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemMoldD.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemMoldH.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRecordD.cs create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRecordH.cs create mode 100644 EquipMgr/Tnb.EquipMgr/ToolMaintainTemService.cs create mode 100644 EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRecordService.cs diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipMaintainRecordQueryOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipMaintainRecordQueryOutput.cs index ada9dbb8..741a7cda 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipMaintainRecordQueryOutput.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipMaintainRecordQueryOutput.cs @@ -9,6 +9,10 @@ namespace Tnb.EquipMgr.Entities.Dto public string? create_time { get; set; } public string? equip_id { get; set; } public string? equip_id_id { get; set; } + + public string? mold_id { get; set; } + public string? mold_id_id { get; set; } + public string? execute_time { get; set; } public string? execute_user_id { get; set; } public string? repeat_remark { get; set; } diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipQueryInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipQueryInput.cs index 623edaa7..3dcdadc8 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipQueryInput.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipQueryInput.cs @@ -3,6 +3,8 @@ namespace Tnb.EquipMgr.Entities.Dto public class EquipQueryInput { public string equip_id { get; set; } = string.Empty; + + public string mold_id { get; set; } = string.Empty; /// /// 当前页码:pageIndex. diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldMaintainPlanRunListOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldMaintainPlanRunListOutput.cs new file mode 100644 index 00000000..e1b63136 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldMaintainPlanRunListOutput.cs @@ -0,0 +1,17 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class ToolMoldMaintainPlanRunListOutput + { + public string id { get; set; } + public string plan_code { get; set; } + public string mode { get; set; } + public string status { get; set; } + public string create_id { get; set; } + public string create_time { get; set; } + public string plan_start_date { get; set; } + public string plan_end_date { get; set; } + public string remark { get; set; } + public string starter_id { get; set; } + public string act_start_date { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldMaintainRecordListOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldMaintainRecordListOutput.cs new file mode 100644 index 00000000..9a1b56d2 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldMaintainRecordListOutput.cs @@ -0,0 +1,27 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class ToolMoldMaintainRecordListOutput + { + public string id { get; set; } + public string mold_id { get; set; } + public string mold_id_id { get; set; } + public string status { get; set; } + public string result { get; set; } + public string result_remark { get; set; } + public string repeat_result { get; set; } + public string repeat_remark { get; set; } + public string create_time { get; set; } + public string execute_time { get; set; } + public string repeat_user_id { get; set; } + public string repeat_user_id_id { get; set; } + public string execute_user_id { get; set; } + public string execute_user_id_id { get; set; } + public string repeat_time { get; set; } + public string last_execute_time { get; set; } + + public DateTime? date_repeat_time { get; set; } + public DateTime? date_create_time { get; set; } + public DateTime? date_execute_time { get; set; } + public DateTime? date_last_execute_time { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldMaintainRecordRepeatOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldMaintainRecordRepeatOutput.cs new file mode 100644 index 00000000..1949f372 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolMoldMaintainRecordRepeatOutput.cs @@ -0,0 +1,9 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class ToolMoldMaintainRecordRepeatOutput + { + public ToolMoldMaintainRecordH? model { get; set; } + + public List? details { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolTemPublishInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolTemPublishInput.cs new file mode 100644 index 00000000..32957c56 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/ToolTemPublishInput.cs @@ -0,0 +1,9 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class ToolTemPublishInput + { + public string? id { get; set; } + + public string[]? moldIds { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainItem.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainItem.cs new file mode 100644 index 00000000..6c09032f --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainItem.cs @@ -0,0 +1,77 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities +{ + /// + /// 设备保养项目 + /// + [SugarTable("tool_maintain_item")] + public class ToolMaintainItem: BaseEntity + { + public ToolMaintainItem() + { + 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; } + + /// + /// 项目编码 + /// + public string? code { get; set; } + + /// + /// 项目名称 + /// + public string? name { get; set; } + + /// + /// 保养类型 + /// + public string? maintain_type { get; set; } + + /// + /// 保养内容 + /// + public string? maintain_content { get; set; } + + /// + /// 描述 + /// + public string? descrip { get; set; } + + /// + /// 备注 + /// + public string? remark { get; set; } + + /// + /// 排序 + /// + public int? ordinal { get; set; } + + /// + /// 所属组织 + /// + public string? org_id { get; set; } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemD.cs new file mode 100644 index 00000000..c3b308b5 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemD.cs @@ -0,0 +1,27 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 模具保养模板子表 +/// +[SugarTable("tool_maintain_tem_d")] +public partial class ToolMaintainTemD : BaseEntity +{ + public ToolMaintainTemD() + { + 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/ToolMaintainTemH.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemH.cs new file mode 100644 index 00000000..76bd9ea3 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemH.cs @@ -0,0 +1,135 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 模具保养模板主表 +/// +[SugarTable("tool_maintain_tem_h")] +public partial class ToolMaintainTemH : BaseEntity +{ + public ToolMaintainTemH() + { + 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; } + + public string? duty_user_id { get; set; } + public string? repeat_user_id { get; set; } + +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemMoldD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemMoldD.cs new file mode 100644 index 00000000..18c1f026 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemMoldD.cs @@ -0,0 +1,27 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 模具保养模具模板子表 +/// +[SugarTable("tool_maintain_tem_mold_d")] +public partial class ToolMaintainTemMoldD : BaseEntity +{ + public ToolMaintainTemMoldD() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 模具保养模具模板主表id + /// + public string maintain_tem_mold_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/ToolMaintainTemMoldH.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemMoldH.cs new file mode 100644 index 00000000..04b2f7a2 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMaintainTemMoldH.cs @@ -0,0 +1,140 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 模具保养模具模板主表 +/// +[SugarTable("tool_maintain_tem_mold_h")] +public partial class ToolMaintainTemMoldH : BaseEntity +{ + public ToolMaintainTemMoldH() + { + 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? mold_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; } + + public string? duty_user_id { get; set; } + public string? repeat_user_id { get; set; } + +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlan.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlan.cs index 65929f93..1eda660b 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlan.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlan.cs @@ -39,6 +39,21 @@ namespace Tnb.EquipMgr.Entities /// 计划完成时间 /// public DateTime? plan_end_date { get; set; } + + /// + /// 实际开始时间 + /// + public DateTime? act_start_date { get; set; } + + /// + /// 开始人 + /// + public string starter_id { get; set; } + + /// + /// 实际结束时间 + /// + public DateTime? act_end_date { get; set; } /// /// 备注 diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRecordD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRecordD.cs new file mode 100644 index 00000000..113c14f7 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRecordD.cs @@ -0,0 +1,92 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 模具保养执行记录子表 +/// +[SugarTable("tool_mold_maintain_record_d")] +public partial class ToolMoldMaintainRecordD : BaseEntity +{ + public ToolMoldMaintainRecordD() + { + 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_mold_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/ToolMoldMaintainRecordH.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRecordH.cs new file mode 100644 index 00000000..5d49f82f --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRecordH.cs @@ -0,0 +1,172 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 模具保养执行记录主表 +/// +[SugarTable("tool_mold_maintain_record_h")] +public partial class ToolMoldMaintainRecordH : BaseEntity +{ + public ToolMoldMaintainRecordH() + { + 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 mold_id { get; set; } = string.Empty; + + /// + /// 模具保养模具模板id + /// + public string maintain_tem_mold_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; } + + /// + /// 复核附件 + /// + public string? fhattachment { get; set; } + +} diff --git a/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs b/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs index 56dde5cc..46ad3c4c 100644 --- a/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs +++ b/EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs @@ -100,16 +100,16 @@ namespace Tnb.EquipMgr .Mapper(a => { a.status = a.status == "1" ? "待执行" : a.status == "2" ? "待复核" : "已完成"; - a.create_time = a.date_create_time == null ? "" : a.date_create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"); - a.execute_time = a.date_execute_time == null ? "" : a.date_execute_time.Value.ToString("yyyy-MM-dd HH:mm:ss"); - a.repeat_time = a.date_repeat_time == null ? "" : a.date_repeat_time.Value.ToString("yyyy-MM-dd HH:mm:ss"); - a.last_execute_time = a.date_last_execute_time == null ? "" : a.date_last_execute_time.Value.ToString("yyyy-MM-dd HH:mm:ss"); + a.create_time = a.date_create_time == null ? "" : a.date_create_time.Value.ToString(DbTimeFormat.SS); + a.execute_time = a.date_execute_time == null ? "" : a.date_execute_time.Value.ToString(DbTimeFormat.SS); + a.repeat_time = a.date_repeat_time == null ? "" : a.date_repeat_time.Value.ToString(DbTimeFormat.SS); + a.last_execute_time = a.date_last_execute_time == null ? "" : a.date_last_execute_time.Value.ToString(DbTimeFormat.SS); }) .ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50); var EqpMaintainRecordHs = await db.Queryable().Where(p => list.list.Select(p => p.equip_id_id).ToList().Contains(p.equip_id)).ToListAsync(); foreach (var data in list.list) { - data.last_execute_time = EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).Any() ? EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).OrderByDescending(x => x.execute_time).FirstOrDefault()!.execute_time!.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""; + data.last_execute_time = EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).Any() ? EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).OrderByDescending(x => x.execute_time).FirstOrDefault()!.execute_time!.Value.ToString(DbTimeFormat.SS) : ""; } return PageResult.SqlSugarPageResult(list); } diff --git a/EquipMgr/Tnb.EquipMgr/ToolMaintainTemService.cs b/EquipMgr/Tnb.EquipMgr/ToolMaintainTemService.cs new file mode 100644 index 00000000..16de6678 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/ToolMaintainTemService.cs @@ -0,0 +1,148 @@ +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; +using Tnb.EquipMgr.Entities.Dto; +using Tnb.EquipMgr.Entities; + +namespace Tnb.MoldMgr +{ + /// + /// 模具保养检模板管理 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class ToolMaintainTemService : IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + + public ToolMaintainTemService(ISqlSugarRepository repository, + IUserManager userManager) + { + _repository = repository; + _userManager = userManager; + } + + /// + /// 根据模板id发布到设备 + /// + [HttpPost] + public async Task Publish(ToolTemPublishInput input) + { + ISqlSugarClient db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => + { + ToolMaintainTemH ToolMaintainTemH = await _repository.GetSingleAsync(x => x.id == input.id); + List ToolMaintainTemDs = await db.Queryable().Where(x => x.maintain_tem_id == input.id).ToListAsync(); + + if (input.moldIds != null && input.moldIds.Length > 0) + { + List insertToolMaintainTemMoldHs = new(); + List insertToolMaintainTemMoldDs = new(); + foreach (string moldId in input.moldIds) + { + string id = SnowflakeIdHelper.NextId(); + string code = $"{DateTime.Now.ToString("yyyyMMdd") + moldId}"; + ToolMaintainTemMoldH ToolMaintainTemMoldH = new() + { + id = id, + code = code, + name = ToolMaintainTemH.name + moldId, + plan_cycle = ToolMaintainTemH.plan_cycle, + plan_cycle_unit = ToolMaintainTemH.plan_cycle_unit, + plan_run_notice = ToolMaintainTemH.plan_run_notice, + plan_delay = ToolMaintainTemH.plan_delay, + start_time = ToolMaintainTemH.start_time, + is_start = ToolMaintainTemH.is_start.ToString(), + is_repeat = ToolMaintainTemH.is_repeat.ToString(), + is_send = ToolMaintainTemH.is_send, + maintain_tem_id = input.id, + mold_id = moldId, + remark = ToolMaintainTemH.remark, + plan_run_notice_unit = ToolMaintainTemH.plan_run_notice_unit, + plan_delay_unit = ToolMaintainTemH.plan_delay_unit, + repeat_post_info_user_id = ToolMaintainTemH.repeat_post_info_user_id, + send_post_info_user_id = ToolMaintainTemH.send_post_info_user_id, + send_post_id = ToolMaintainTemH.send_post_id, + org_id = ToolMaintainTemH.org_id, + create_id = _userManager.UserId, + create_time = DateTime.Now, + duty_user_id= ToolMaintainTemH.duty_user_id, + repeat_user_id= ToolMaintainTemH.repeat_user_id + }; + insertToolMaintainTemMoldHs.Add(ToolMaintainTemMoldH); + + if (ToolMaintainTemDs != null && ToolMaintainTemDs.Count > 0) + { + foreach (ToolMaintainTemD ToolMaintainTem in ToolMaintainTemDs) + { + ToolMaintainTemMoldD ToolMaintainTemMoldD = new() + { + id = SnowflakeIdHelper.NextId(), + maintain_item_id = ToolMaintainTem.maintain_item_id, + maintain_tem_mold_id = id, + }; + insertToolMaintainTemMoldDs.Add(ToolMaintainTemMoldD); + } + } + + ToolMaintainTemMoldH oldMaintainTemMoldH = await db.Queryable().Where(x => x.maintain_tem_id == input.id && x.mold_id == moldId).FirstAsync(); + _ = await db.Deleteable().Where(x => x.maintain_tem_id == input.id && x.mold_id == moldId).ExecuteCommandAsync(); + if (oldMaintainTemMoldH != null) + { + _ = await db.Deleteable().Where(x => x.maintain_tem_mold_id == oldMaintainTemMoldH.id).ExecuteCommandAsync(); + } + } + + if (insertToolMaintainTemMoldHs != null && insertToolMaintainTemMoldHs.Count > 0) + { + _ = await db.Insertable(insertToolMaintainTemMoldHs).ExecuteCommandAsync(); + } + + if (insertToolMaintainTemMoldDs != null && insertToolMaintainTemMoldDs.Count > 0) + { + _ = await db.Insertable(insertToolMaintainTemMoldDs).ExecuteCommandAsync(); + } + + } + + }); + + return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : result.IsSuccess ? "发布成功" : result.ErrorMessage; + } + + [HttpPost] + public async Task Stop(Dictionary parameters) + { + string id = parameters["id"]; + var db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => + { + await db.Updateable() + .SetColumns(x => x.is_start == "0") + .Where(x => x.id == id) + .ExecuteCommandAsync(); + List ids = await _repository.AsSugarClient().Queryable() + .Where(x => x.maintain_tem_mold_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED) + .Select(x => x.id).ToListAsync(); + _ = await _repository.AsSugarClient().Deleteable() + .Where(x => x.maintain_tem_mold_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/ToolMoldMaintainRecordService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRecordService.cs new file mode 100644 index 00000000..9b5ca597 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRecordService.cs @@ -0,0 +1,304 @@ +using JNPF.Common.Core.Manager; +using JNPF.Common.Enums; +using JNPF.Common.Filter; +using JNPF.Common.Security; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Entitys.System; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; +using JNPF.VisualDev.Interfaces; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using SqlSugar; +using Tnb.BasicData; +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 ToolMoldMaintainRecordService : IOverideVisualDevService, IDynamicApiController, ITransient + { + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + private const string ModuleId = "35902722254101"; + private readonly ISqlSugarRepository _repository; + private readonly IVisualDevService _visualDevService; + private readonly IRunService _runService; + private readonly IUserManager _userManager; + + public ToolMoldMaintainRecordService(ISqlSugarRepository repository, + IRunService runService, + IUserManager userManager, + IVisualDevService visualDevService) + { + _repository = repository; + _visualDevService = visualDevService; + _runService = runService; + _userManager = userManager; + OverideFuncs.GetListAsync = GetList; + // OverideFuncs.UpdateAsync = ExecuteSpotIns; + } + + private async Task GetList(VisualDevModelListQueryInput input) + { + ISqlSugarClient db = _repository.AsSugarClient(); + Dictionary? queryJson = (input == null || string.IsNullOrEmpty(input.queryJson)) ? new Dictionary() : input.queryJson.ToObject>(); + string moldInfo = queryJson.ContainsKey("query_info") ? (queryJson["query_info"].ToString() ?? "") : ""; + string status = queryJson.ContainsKey("status") ? (queryJson["status"].ToString() ?? "") : ""; + DateTime? start_time = queryJson.ContainsKey("start_time") ? queryJson["start_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["start_time"]) : null; + DateTime? end_time = queryJson.ContainsKey("end_time") ? queryJson["end_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["end_time"]) : null; + + if (string.IsNullOrEmpty(input.sidx)) + { + input.sidx = "a.create_time"; + input.sort = "desc"; + } + else + { + input.sidx = "a." + input.sidx; + } + + SqlSugarPagedList list = await db.Queryable((a, b, c, d) => new object[] + { + JoinType.Left, a.mold_id == b.id, + JoinType.Left, a.execute_user_id == c.Id, + JoinType.Left, a.repeat_user_id == d.Id, + }) + .WhereIF(!string.IsNullOrEmpty(status), (a, b, c) => a.status == status) + .WhereIF(!string.IsNullOrEmpty(moldInfo), (a, b, c) => b.mold_code.Contains(moldInfo) || b.mold_name.Contains(moldInfo)) + .WhereIF(status == "3" && start_time != null, a => a.execute_time >= start_time) + .WhereIF(status == "3" && end_time != null, a => a.execute_time <= end_time) + .OrderBy($"{input.sidx} {input.sort}") + .Select((a, b, c, d) => new ToolMoldMaintainRecordListOutput + { + id = a.id, + mold_id = b.mold_code + "/" + b.mold_name, + mold_id_id = a.mold_id, + status = a.status, + result = a.result == "1" ? "合格" : "不合格", + repeat_result = a.repeat_result == "1" ? "合格" : "不合格", + date_create_time = a.create_time, + date_execute_time = a.execute_time, + date_repeat_time = a.repeat_time, + execute_user_id = c.RealName, + execute_user_id_id = a.execute_user_id, + repeat_user_id = d.RealName, + repeat_user_id_id = a.repeat_user_id, + result_remark = a.result_remark, + repeat_remark = a.repeat_remark, + date_last_execute_time = SqlFunc.Subqueryable().Where(x => a.mold_id == x.mold_id && a.execute_time != null).OrderByDesc(x => x.execute_time).Select(x => x.execute_time) + }) + .Mapper(a => + { + a.status = a.status == "1" ? "待执行" : a.status == "2" ? "待复核" : "已完成"; + a.create_time = a.date_create_time == null ? "" : a.date_create_time.Value.ToString(DbTimeFormat.SS); + a.execute_time = a.date_execute_time == null ? "" : a.date_execute_time.Value.ToString(DbTimeFormat.SS); + a.repeat_time = a.date_repeat_time == null ? "" : a.date_repeat_time.Value.ToString(DbTimeFormat.SS); + a.last_execute_time = a.date_last_execute_time == null ? "" : a.date_last_execute_time.Value.ToString(DbTimeFormat.SS); + }) + .ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50); + var ToolMoldMaintainRecordHs = await db.Queryable().Where(p => list.list.Select(p => p.mold_id_id).ToList().Contains(p.mold_id)).ToListAsync(); + foreach (var data in list.list) + { + data.last_execute_time = ToolMoldMaintainRecordHs.Where(x => data.mold_id_id == x.mold_id && x.execute_time != null).Any() ? ToolMoldMaintainRecordHs.Where(x => data.mold_id_id == x.mold_id && x.execute_time != null).OrderByDescending(x => x.execute_time).FirstOrDefault()!.execute_time!.Value.ToString(DbTimeFormat.SS) : ""; + } + return PageResult.SqlSugarPageResult(list); + } + + /// + /// 执行模具保养计划 + /// + /// + [HttpPost] + public async Task ExecuteMaintain(SpotInsRecordExecuteInput input) + { + DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () => + { + ToolMoldMaintainRecordH eqpSpotInsRecordH = _repository.GetSingle(x => x.id == input.id); + string status = eqpSpotInsRecordH.is_repeat == "1" ? SpotInsRecordExecutionStatus.TOBECHECK : SpotInsRecordExecutionStatus.COMPLETED; + _ = await _repository.UpdateAsync(x => new ToolMoldMaintainRecordH() + { + 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); + + if (input != null && input.details != null) + { + foreach (Dictionary item in input.details) + { + _ = await _repository.AsSugarClient().Updateable() + .SetColumns(x => x.result == item["result"]) + .SetColumnsIF(item.ContainsKey("maintain_descrip"), x => x.maintain_descrip == item["maintain_descrip"]) + .Where(x => x.id == item["id"]) + .ExecuteCommandAsync(); + } + } + + + }); + + return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result.IsSuccess ? "执行成功" : result.ErrorMessage); + } + + /// + /// 获取模具保养计划复核信息 + /// + /// + /// + [HttpPost] + public async Task GetMaintainRecordRepeatInfo(Dictionary dic) + { + string id = dic["id"]; + ToolMoldMaintainRecordH eqpSpotInsRecordH = await _repository.GetSingleAsync(x => x.id == id); + ToolMolds toolMolds = await _repository.AsSugarClient().Queryable().SingleAsync(x=>x.id==eqpSpotInsRecordH.mold_id); + List eqpSpotInsRecordDs = await _repository.AsSugarClient().Queryable() + .Where(x => x.maintain_record_id == id).ToListAsync(); + Dictionary typeDic = await _repository.AsSugarClient().Queryable() + .LeftJoin((a, b) => a.Id == b.DictionaryTypeId) + .Where((a, b) => a.EnCode == DictConst.EqpMaintainType) + .Select((a, b) => new + { + b.EnCode, + b.FullName + }) + .MergeTable() + .ToDictionaryAsync(it => it.EnCode, it => it.FullName); + eqpSpotInsRecordDs.ForEach(x => + { + x.maintain_type = typeDic.ContainsKey(x.maintain_type) ? typeDic[x.maintain_type] + "" : x.maintain_type; + }); + // eqpSpotInsRecordH.mold_id = (toolMolds?.mold_code ?? "") + "/" + (toolMolds?.mold_name ?? ""); + ToolMoldMaintainRecordRepeatOutput output = new() + { + model = eqpSpotInsRecordH, + details = eqpSpotInsRecordDs, + }; + return output; + } + + /// + /// 复核模具保养计划 + /// + /// + [HttpPost] + public async Task RepeatMaintain(MaintainRecordRepeatInput input) + { + ISqlSugarClient db = _repository.AsSugarClient(); + ToolMoldMaintainRecordH toolMoldMaintainRecordH = await _repository.GetSingleAsync(x => x.id == input.id); + if (toolMoldMaintainRecordH.status == "1") + { + throw Oops.Bah("状态错误"); + } + DbResult result = await db.Ado.UseTranAsync(async () => + { + + if (input != null && input.details != null) + { + foreach (Dictionary item in input.details) + { + _ = await db.Updateable() + .SetColumnsIF(item.ContainsKey("repeat_descrip"), x => x.repeat_descrip == item["repeat_descrip"]) + .SetColumns(x => x.repeat_result == item["repeat_result"]) + .Where(x => x.id == item["id"]).ExecuteCommandAsync(); + } + } + + if (input != null) + { + _ = await _repository.UpdateAsync(x => new ToolMoldMaintainRecordH() + { + fhattachment=input.attachment, + 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); + } + }); + + return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : result.IsSuccess ? "复核成功" : result.ErrorMessage; + } + + [HttpPost] + public async Task GetMaintainRecordList(EquipQueryInput input) + { + ISqlSugarClient db = _repository.AsSugarClient(); + Dictionary? queryJson = new(); + if (!string.IsNullOrEmpty(input.queryJson)) + { + queryJson = JsonConvert.DeserializeObject>(input.queryJson); + } + SqlSugarPagedList result = await db.Queryable() + .LeftJoin((a, b) => a.mold_id == b.id) + .LeftJoin((a, b, c) => a.execute_user_id == c.Id) + .LeftJoin((a, b, c, d) => a.repeat_user_id == d.Id) + .Where(a => a.mold_id == input.mold_id) + .Select((a, b, c, d) => new EquipMaintainRecordQueryOutput + { + id = a.id, + attachment = a.attachment, + fhattachment= a.fhattachment, + create_time = a.create_time == null ? null : a.create_time.Value.ToString(DbTimeFormat.MM), + mold_id = b.mold_code, + mold_id_id = a.mold_id, + repeat_remark = a.repeat_remark, + repeat_result = a.repeat_result == "1" ? "合格" : "不合格", + repeat_time = a.repeat_time == null ? null : a.repeat_time.Value.ToString(DbTimeFormat.MM), + repeat_user_id = d.RealName, + result = a.result == "1" ? "合格" : "不合格", + result_remark = a.result_remark, + maintain_tem_equip_id = a.maintain_tem_mold_id, + execute_time = a.execute_time == null ? null : a.execute_time.Value.ToString(DbTimeFormat.MM), + execute_user_id = c.RealName, + status = SqlFunc.IF(a.status.Equals("1")).Return("待执行").ElseIF(a.status.Equals("2")).Return("待复核").ElseIF(a.status.Equals("3")).Return("已完成").End("") + }).ToPagedListAsync(input.currentPage, input.pageSize); + + return PageResult.SqlSugarPageResult(result); + } + + /// + /// 根据id获取保养相关信息 + /// + /// + [HttpPost] + public async Task GetEqpMaintainRecordInfoById(Dictionary dic) + { + string id = dic.ContainsKey("id") ? dic["id"] : ""; + if (string.IsNullOrEmpty(id)) + { + return null; + } + + ISqlSugarClient db = _repository.AsSugarClient(); + return await db.Queryable() + .LeftJoin((a, b) => a.mold_id == b.id) + .Where((a, b) => a.id == id) + .Select((a, b) => new + { + a.id, + a.mold_id, + mold_code = b.mold_code, + mold_name = b.mold_name, + create_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS), + a.result_remark, + a.result, + a.status, + }).FirstAsync(); + + } + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs index 33d3de12..49921398 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs @@ -60,6 +60,7 @@ namespace Tnb.EquipMgr ToolMoldMaintainRule toolMoldMaintainRule = new() { id = SnowflakeIdHelper.NextId(), + name = input.data["name"].ToString(), mode = input.data["mode"].ToString(), cycle = cycle, startandend_date = startTime.ToString("yyyy-MM-dd HH:mm:ss"), diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs index 651c3855..601993c7 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs @@ -2,6 +2,7 @@ using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.Common.Filter; +using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; @@ -9,7 +10,11 @@ using JNPF.Logging; using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Entitys.System; using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; +using JNPF.VisualDev.Interfaces; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json.Linq; using SqlSugar; using StackExchange.Profiling.Internal; using Tnb.BasicData; @@ -25,18 +30,71 @@ namespace Tnb.EquipMgr /// [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] [Route("api/[area]/[controller]/[action]")] - - public class ToolMoldMaintainPlanRunService : IToolMoldMaintainPlanRunService, IDynamicApiController, ITransient + [OverideVisualDev(ModuleId)] + public class ToolMoldMaintainPlanRunService : IOverideVisualDevService,IToolMoldMaintainPlanRunService, IDynamicApiController, ITransient { + private const string ModuleId = "26186915586085"; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; private readonly ISqlSugarClient _db; private readonly IUserManager _userManager; private readonly IDictionaryDataService _dictionaryDataService; + + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); - public ToolMoldMaintainPlanRunService(ISqlSugarRepository repository, IUserManager userManager, IDictionaryDataService dictionaryDataService) + public ToolMoldMaintainPlanRunService(ISqlSugarRepository repository, + IUserManager userManager, + IRunService runService, + IVisualDevService visualDevService, + IDictionaryDataService dictionaryDataService) { _db = repository.AsSugarClient(); + _runService = runService; + _visualDevService = visualDevService; _userManager = userManager; _dictionaryDataService = dictionaryDataService; + OverideFuncs.GetListAsync = GetList; + } + + /// + /// 生产bom列表 + /// + /// + /// + public async Task GetList(VisualDevModelListQueryInput input) + { + Dictionary queryJson = string.IsNullOrEmpty(input.queryJson) ? new Dictionary() : input.queryJson.ToObject>(); + string planCode = queryJson.GetValueOrDefault("plan_code", "").ToString(); + string status = queryJson.GetValueOrDefault("status", "").ToString(); + DateTime[] planStartDateArr = queryJson.ContainsKey("plan_start_date") ? queryJson["plan_start_date"].ToObject().Select(x => DateTimeOffset.FromUnixTimeSeconds(x / 1000).ToLocalTime().DateTime).ToArray() : null; + DateTime[] planEndDateArr = queryJson.ContainsKey("plan_end_date") ? queryJson["plan_end_date"].ToObject().Select(x => DateTimeOffset.FromUnixTimeSeconds(x / 1000).ToLocalTime().DateTime).ToArray() : null; + SqlSugarPagedList list = await _db.Queryable((a, b, c, d,e) => new object[] + { + JoinType.Left, a.mode == b.Id, + JoinType.Left, a.create_id == c.Id, + JoinType.Left,a.status==d.EnCode && d.DictionaryTypeId==DictConst.MaintainStatusTypeId, + JoinType.Left, a.starter_id == e.Id, + }) + .WhereIF(!string.IsNullOrEmpty(planCode), (a, b, c, d) => a.plan_code.Contains(planCode)) + .WhereIF(!string.IsNullOrEmpty(status), (a, b, c, d) => a.status==status) + .WhereIF(planStartDateArr!=null,(a, b, c, d) =>a.plan_start_date>=planStartDateArr[0] && a.plan_start_date<=planStartDateArr[1]) + .WhereIF(planEndDateArr!=null,(a, b, c, d) =>a.plan_end_date>=planEndDateArr[0] && a.plan_end_date<=planEndDateArr[1]) + .Select((a, b, c, d,e) => new ToolMoldMaintainPlanRunListOutput + { + id = a.id, + plan_code = a.plan_code, + mode = b.FullName, + status = d.FullName, + create_id = c.RealName, + create_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS), + plan_start_date = a.plan_start_date == null ? "" : a.plan_start_date.Value.ToString(DbTimeFormat.SS), + plan_end_date = a.plan_end_date == null ? "" : a.plan_end_date.Value.ToString(DbTimeFormat.SS), + remark = a.remark, + act_start_date = a.act_start_date == null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS), + starter_id = e.RealName, + }).ToPagedListAsync(input.currentPage, input.pageSize); + + return PageResult.SqlSugarPageResult(list); } /// @@ -367,6 +425,13 @@ namespace Tnb.EquipMgr if (plan is not null) { + + await _db.Updateable() + .SetColumns(x => x.act_start_date == DateTime.Now) + .SetColumns(x => x.starter_id == _userManager.UserId) + .Where(x => x.id == plan.id) + .ExecuteCommandAsync(); + //插入保养计划记录 ToolMoldMaintainRunRecord record = new() { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index 38203e84..f268e43a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -131,22 +131,22 @@ namespace Tnb.WarehouseMgr .Where((x, y) => x.EnCode == DictConst.MeasurementUnit && unitCodes.Contains(y.EnCode)) .Select((x,y)=>y) .ToListAsync(); + WmsPurchaseOrderH wmsPurchaseOrderH = await _db.Queryable().SingleAsync(x=>x.id==purchase.erp_bill_code); + //todo 先取采购订单第一条 + WmsPurchaseOrderD wmsPurchaseOrderDs = await _db.Queryable().FirstAsync(x=>x.fk_wms_purchase_order_id==purchase.erp_bill_code); List ids = new List(); ids.Add(_userManager.UserId); ids.Add(WmsWareHouseConst.AdministratorOrgId); ids.Add(purchase.warehouse_id); ids.AddRange(materialIds); - ids.Add(purchase.supplier_id); + ids.Add(wmsPurchaseOrderH.supplier_id); ids.AddRange(unitDatas.Select(x=>x.Id).ToList()); List erpExtendFields = await _db.Queryable().Where(x=>ids.Contains(x.table_id)).ToListAsync(); string erpCreateId = erpExtendFields.Find(x=>x.table_id==_userManager.UserId)?.user_id ?? ""; ErpExtendField erpOrg = erpExtendFields.Find(x => x.table_id == (WmsWareHouseConst.AdministratorOrgId)); string nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - WmsPurchaseOrderH wmsPurchaseOrderH = await _db.Queryable().SingleAsync(x=>x.id==purchase.erp_bill_code); - //todo 先取采购订单第一条 - WmsPurchaseOrderD wmsPurchaseOrderDs = await _db.Queryable().FirstAsync(x=>x.fk_wms_purchase_order_id==purchase.erp_bill_code); List> requestData = new List>(); Dictionary erpRequestData = new Dictionary(); @@ -165,6 +165,7 @@ namespace Tnb.WarehouseMgr erpRequestData.Add("pk_org_v",erpOrg.pk_org_v); erpRequestData.Add("pk_group",erpOrg.pk_group); erpRequestData.Add("pk_pupsndoc",""); + erpRequestData.Add("csourceid", wmsPurchaseOrderH?.erp_pk ?? ""); erpRequestData.Add("pk_purchaseorg",erpOrg.pk_org); erpRequestData.Add("pk_purchaseorg_v",erpOrg.pk_org_v); erpRequestData.Add("pk_supplier",erpExtendFields.Find(x=>x.table_id==purchase.supplier_id)?.supplier_id ?? "");//先写死 @@ -183,7 +184,7 @@ namespace Tnb.WarehouseMgr ["cfirstid"] = wmsPurchaseOrderDs.erp_line_pk, ["cfirsttypecode"] = "", ["crececountryid"] = "0001Z010000000079UJJ", - ["crowno"] = (dList.FindIndex(x=>x.id==item.id)+1) * 10, + ["crowno"] = wmsPurchaseOrderDs.lineno, ["csendcountryid"] = "0001Z010000000079UJJ", ["csourcetypecode"] = "", ["ctaxcountryid"] = "0001Z010000000079UJJ", @@ -202,7 +203,7 @@ namespace Tnb.WarehouseMgr ["pk_apfinanceorg_v"] = erpOrg.pk_org_v, ["pk_arriveorder"] = null, ["pk_arriveorder_b"] = null, - ["pk_group"] = "", + ["pk_group"] = erpOrg.pk_group, ["csourcebid"] = wmsPurchaseOrderDs.erp_line_pk, ["csourceid"] = wmsPurchaseOrderH?.erp_pk ?? "", ["pk_material"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialoid ?? "", diff --git a/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs b/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs index 64fbc34b..644e035d 100644 --- a/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs +++ b/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs @@ -9,33 +9,36 @@ using Tnb.EquipMgr.Entities; namespace JNPF.TaskScheduler.Listener { /// - /// 生成设备保养计划 + /// 生成保养计划 /// public class GenerateMaintainPlanTimeWorker : ISpareTimeWorker { - private ISqlSugarRepository _repository => App.GetService>(); - // public GenerateSpotInspectionPlanTimeWorker(ISqlSugarRepository repository) + private ISqlSugarRepository _repository => App.GetService>(); + // public GenerateSpotInspectionPlanTimeWorker(ISqlSugarRepository repository) // { // _repository = repository; // } private IMessageService _sendMessageService => App.GetService(); - [SpareTime("0 0 0 * * ?", "生成设备保养计划", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)] + [SpareTime("0 0 0 * * ?", "生成保养计划", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)] public async void GenerateSpotInspectionPlan(SpareTimer timer, long count) { - Log.Information("----------------------开始生成设备保养计划----------------------"); - + Log.Information("----------------------开始生成保养计划----------------------"); + var db = _repository.CopyNew(); try { - var db = _repository.CopyNew(); - List eqpSpotInsTemEquipHsByOne = await db.Queryable().Where(x => x.is_start == "1" && x.plan_cycle_unit == "1").ToListAsync(); - List eqpSpotInsTemEquipHsByCirculate = await db.Queryable().Where(x => x.is_start == "1" && x.plan_cycle_unit == "2").ToListAsync(); + //设备保养 + List eqpSpotInsTemEquipHsByOne = await db.Queryable() + .Where(x => x.is_start == "1" && x.plan_cycle_unit == "1").ToListAsync(); + List eqpSpotInsTemEquipHsByCirculate = await db.Queryable() + .Where(x => x.is_start == "1" && x.plan_cycle_unit == "2").ToListAsync(); List tobeCreateList = new List(); List tobeCreateTemplets = new List(); foreach (var item in eqpSpotInsTemEquipHsByOne) { - if (item.start_time.AddDays((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); } @@ -55,37 +58,43 @@ namespace JNPF.TaskScheduler.Listener // tobeCreateTemplets.Add(item); // } // } - + //按上一个保养记录来生成数据 foreach (var item in eqpSpotInsTemEquipHsByCirculate) { - EqpMaintainRecordH eqpMaintainRecordH = await db.Queryable().Where(x=>x.maintain_tem_equip_id==item.id).OrderByDescending(x=>x.create_time).FirstAsync(); + EqpMaintainRecordH eqpMaintainRecordH = await db.Queryable() + .Where(x => x.maintain_tem_equip_id == item.id).OrderByDescending(x => x.create_time) + .FirstAsync(); if (eqpMaintainRecordH == null) { 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); - } - }else if (eqpMaintainRecordH.status!="1") - { - TimeSpan ts1 = new TimeSpan(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")).Ticks); - TimeSpan ts2 = new TimeSpan(Convert.ToDateTime(eqpMaintainRecordH.execute_time.Value.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); } } - + else if (eqpMaintainRecordH.status != "1") + { + TimeSpan ts1 = new TimeSpan(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")).Ticks); + TimeSpan ts2 = new TimeSpan(Convert + .ToDateTime(eqpMaintainRecordH.execute_time.Value.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 = await db.Queryable().Where(x => x.life == Tnb.EquipMgr.EquipmentLife.ENABLE).ToListAsync(); + List equipments = await db.Queryable() + .Where(x => x.life == Tnb.EquipMgr.EquipmentLife.ENABLE).ToListAsync(); int index = 1; foreach (var item in tobeCreateTemplets) { @@ -111,8 +120,8 @@ namespace JNPF.TaskScheduler.Listener repeat_user_id = item.repeat_user_id, execute_user_id = item.duty_user_id, create_time = DateTime.Now, - - + + status = Tnb.EquipMgr.SpotInsRecordExecutionStatus.TOBEEXECUTED }); } @@ -122,9 +131,11 @@ namespace JNPF.TaskScheduler.Listener if (tobeCreateList != null && tobeCreateList.Count > 0) { List templetIDs = tobeCreateList.Select(x => x.maintain_tem_equip_id).ToList(); - List spotInsTemEquipDs = await db.Queryable().Where(x => templetIDs.Contains(x.maintain_tem_equip_id)).ToListAsync(); + List spotInsTemEquipDs = await db.Queryable() + .Where(x => templetIDs.Contains(x.maintain_tem_equip_id)).ToListAsync(); List spotInsItemIDs = spotInsTemEquipDs.Select(x => x.maintain_item_id).ToList(); - List spotCheckItems = await db.Queryable().Where(x => spotInsItemIDs.Contains(x.id)).ToListAsync(); + List spotCheckItems = await db.Queryable() + .Where(x => spotInsItemIDs.Contains(x.id)).ToListAsync(); List spotInsRecordDs = new List(); @@ -133,7 +144,8 @@ namespace JNPF.TaskScheduler.Listener 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(); + List tobeCreateItems = + spotCheckItems.Where(x => spotInsItems.Contains(x.id)).ToList(); foreach (var tobeCreateItem in tobeCreateItems) { spotInsRecordDs.Add(new EqpMaintainRecordD() @@ -152,6 +164,7 @@ namespace JNPF.TaskScheduler.Listener } } + if (spotInsRecordDs.Count <= 0) { return; @@ -176,7 +189,8 @@ namespace JNPF.TaskScheduler.Listener } else { - List equipments = await db.Queryable().Where(x => x.life == Tnb.EquipMgr.EquipmentLife.ENABLE).ToListAsync(); + List equipments = await db.Queryable() + .Where(x => x.life == Tnb.EquipMgr.EquipmentLife.ENABLE).ToListAsync(); foreach (var item in tobeCreateList) { try @@ -187,22 +201,212 @@ namespace JNPF.TaskScheduler.Listener var title = equipments.FirstOrDefault(x => x.id == item.equip_id).code + "设备保养提醒"; await _sendMessageService.SentMessage(users, title, title); } - catch (Exception) + catch (Exception e) { + Log.Error(e.Message); } } } + Log.Information($"---------------生成{tobeCreateList.Count}个计划---------------"); } + + + //模具保养 + List toolMoldByOne = await db.Queryable() + .Where(x => x.is_start == "1" && x.plan_cycle_unit == "1").ToListAsync(); + List toolMoldByCirculate = await db.Queryable() + .Where(x => x.is_start == "1" && x.plan_cycle_unit == "2").ToListAsync(); + List toolMoldTobeCreateList = new List(); + List toolMoldTobeCreateTemplets = new List(); + + + foreach (var item in toolMoldByOne) + { + if (item.start_time.AddDays((double)item.plan_cycle).ToString("yyyy-MM-dd") == + DateTime.Now.ToString("yyyy-MM-dd")) + { + toolMoldTobeCreateTemplets.Add(item); + } + } + + if (toolMoldByCirculate != null && toolMoldByCirculate.Count > 0) + { + + //整除表示一个周期到了 + // foreach (var item in toolMoldByCirculate) + // { + // 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) + // { + // toolMoldTobeCreateTemplets.Add(item); + // } + // } + + //按上一个保养记录来生成数据 + foreach (var item in toolMoldByCirculate) + { + ToolMoldMaintainRecordH eqpMaintainRecordH = await db.Queryable() + .Where(x => x.maintain_tem_mold_id == item.id).OrderByDescending(x => x.create_time) + .FirstAsync(); + if (eqpMaintainRecordH == null) + { + 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) + { + toolMoldTobeCreateTemplets.Add(item); + } + } + else if (eqpMaintainRecordH.status != "1") + { + TimeSpan ts1 = new TimeSpan(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")).Ticks); + TimeSpan ts2 = new TimeSpan(Convert + .ToDateTime(eqpMaintainRecordH.execute_time.Value.ToString("yyyy-MM-dd")).Ticks); + TimeSpan ts3 = ts1.Subtract(ts2).Duration(); + if (ts3.TotalDays * 10 % (10 * (double)item.plan_cycle) == 0) + { + toolMoldTobeCreateTemplets.Add(item); + } + } + + } + } + + if (toolMoldTobeCreateTemplets != null && toolMoldTobeCreateTemplets.Count > 0) + { + List toolMoldList = await db.Queryable().ToListAsync(); + int index = 1; + foreach (var item in toolMoldTobeCreateTemplets) + { + //只有启用设备才生成计划 + if (toolMoldList.FirstOrDefault(x => x.id == item.mold_id) == null) + continue; + + string code = $"{DateTime.Now.ToString("yyyyMMdd") + (index++).ToString().PadLeft(3, '0')}"; + toolMoldTobeCreateList.Add(new ToolMoldMaintainRecordH() + { + code = code, + // equip_type_id = item.equip_type_id, + mold_id = item.mold_id, + maintain_tem_mold_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, + repeat_user_id = item.repeat_user_id, + execute_user_id = item.duty_user_id, + create_time = DateTime.Now, + + + status = Tnb.EquipMgr.SpotInsRecordExecutionStatus.TOBEEXECUTED + }); + } + } + + + if (toolMoldTobeCreateList != null && toolMoldTobeCreateList.Count > 0) + { + List templetIDs = toolMoldTobeCreateList.Select(x => x.maintain_tem_mold_id).ToList(); + List spotInsTemEquipDs = await db.Queryable() + .Where(x => templetIDs.Contains(x.maintain_tem_mold_id)).ToListAsync(); + List spotInsItemIDs = spotInsTemEquipDs.Select(x => x.maintain_item_id).ToList(); + List spotCheckItems = await db.Queryable() + .Where(x => spotInsItemIDs.Contains(x.id)).ToListAsync(); + + + List spotInsRecordDs = new List(); + foreach (var tobeCreatePlan in toolMoldTobeCreateList) + { + List spotInsItems = spotInsTemEquipDs + .Where(x => x.maintain_tem_mold_id == tobeCreatePlan.maintain_tem_mold_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 ToolMoldMaintainRecordD() + { + id = SnowflakeIdHelper.NextId(), + maintain_record_id = tobeCreatePlan.id, + maintain_tem_mold_id = tobeCreatePlan.maintain_tem_mold_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 + }); + } + + } + + if (spotInsRecordDs.Count <= 0) + { + return; + } + + var dbResult = db.Ado.UseTran(() => + { + if (toolMoldTobeCreateList != null && toolMoldTobeCreateList.Count > 0) + { + db.Insertable(toolMoldTobeCreateList).ExecuteCommand(); + } + + if (spotInsRecordDs != null && spotInsRecordDs.Count > 0) + { + db.Insertable(spotInsRecordDs).ExecuteCommand(); + } + }); + if (!dbResult.IsSuccess) + { + Console.WriteLine(dbResult.ErrorMessage); + Log.Error(dbResult.ErrorMessage); + } + else + { + List toolMoldList = await db.Queryable().ToListAsync(); + foreach (var item in toolMoldTobeCreateList) + { + try + { + if (toolMoldList.FirstOrDefault(x => x.id == item.mold_id) == null) + continue; + var users = new List() { item.execute_user_id }; + var title = toolMoldList.FirstOrDefault(x => x.id == item.mold_id).mold_code + "模具保养提醒"; + await _sendMessageService.SentMessage(users, title, title); + } + catch (Exception e) + { + Log.Error(e.Message); + } + } + } + + Log.Information($"---------------生成{toolMoldTobeCreateList.Count}个计划---------------"); + } } catch (Exception e) { Console.WriteLine(e.Message); Log.Error(e.Message); } + finally + { + db.Dispose(); + } - Log.Information("----------------------结束生成设备保养计划----------------------"); + Log.Information("----------------------结束生成保养计划----------------------"); } } } \ No newline at end of file diff --git a/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpEquipCheckPlanTimeWorker.cs b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpEquipCheckPlanTimeWorker.cs index dc39847b..3ae97be9 100644 --- a/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpEquipCheckPlanTimeWorker.cs +++ b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpEquipCheckPlanTimeWorker.cs @@ -17,9 +17,9 @@ namespace JNPF.TaskScheduler.Listener { Log.Information("----------------------开始生成特种设备检验计划----------------------"); + var db = _repository.CopyNew(); try { - var db = _repository.AsSugarClient(); List ids = _repository.GetList(x => x.status == "0").Select(x => x.equip_id).Distinct() .ToList(); @@ -86,7 +86,10 @@ namespace JNPF.TaskScheduler.Listener Console.WriteLine(e.Message); Log.Error(e.Message); } - + finally + { + db.Dispose(); + } Log.Information("----------------------结束生成特种设备检验计划----------------------"); } diff --git a/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs index a473253d..da72c4d9 100644 --- a/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs +++ b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs @@ -22,9 +22,9 @@ namespace JNPF.TaskScheduler.Listener { Log.Information("----------------------开始生成点巡检计划----------------------"); + var db = _repository.CopyNew(); try { - var db = _repository.CopyNew(); List eqpSpotInsTemEquipHsByOne = await db.Queryable().Where(x => x.is_start == "1" && x.plan_cycle_unit == "1").ToListAsync(); List eqpSpotInsTemEquipHsByCirculate = await db.Queryable().Where(x => x.is_start == "1" && x.plan_cycle_unit == "2").ToListAsync(); List tobeCreateList = new List(); @@ -199,7 +199,10 @@ namespace JNPF.TaskScheduler.Listener Console.WriteLine(e.Message); Log.Error(e.Message); } - + finally + { + db.Dispose(); + } Log.Information("----------------------结束生成点巡检计划----------------------"); }