From ab6c817864f6ff1ee48b45dd521c1298d6d852f4 Mon Sep 17 00:00:00 2001 From: wenjy Date: Thu, 7 Nov 2024 13:35:00 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E6=B7=BB=E5=8A=A0=E5=B7=A1?= =?UTF-8?q?=E6=A3=80=E6=A8=A1=E5=BC=8F=EF=BC=8C=E4=BC=98=E5=8C=96=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=A8=A1=E5=BC=8F=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...utoTaskBusiness.cs => AutoModeBusiness.cs} | 115 ++++- SlnMesnac.Business/InspModeBusiness.cs | 59 +++ SlnMesnac.Business/ManualModeBusiness.cs | 35 ++ SlnMesnac.Business/base/BaseBusiness.cs | 4 +- SlnMesnac.Config/AppConfig.cs | 5 + .../Templates/Service/Impl/Services.vm | 2 +- SlnMesnac.Model/domain/record_busbar_temp.cs | 145 +++++++ .../domain/record_inspection_cabinet.cs | 91 ++++ .../service/IRecord_busbar_tempService.cs | 13 + .../IRecord_inspection_cabinetService.cs | 13 + .../Impl/Record_busbar_tempServiceImpl.cs | 14 + .../Record_inspection_cabinetServiceImpl.cs | 14 + SlnMesnac.WPF/Page/IndexControl.xaml | 20 +- SlnMesnac.WPF/Page/IndexControl.xaml.cs | 402 +++++++++++------- SlnMesnac.WPF/appsettings.json | 1 + 15 files changed, 753 insertions(+), 180 deletions(-) rename SlnMesnac.Business/{AutoTaskBusiness.cs => AutoModeBusiness.cs} (58%) create mode 100644 SlnMesnac.Business/InspModeBusiness.cs create mode 100644 SlnMesnac.Business/ManualModeBusiness.cs create mode 100644 SlnMesnac.Model/domain/record_busbar_temp.cs create mode 100644 SlnMesnac.Model/domain/record_inspection_cabinet.cs create mode 100644 SlnMesnac.Repository/service/IRecord_busbar_tempService.cs create mode 100644 SlnMesnac.Repository/service/IRecord_inspection_cabinetService.cs create mode 100644 SlnMesnac.Repository/service/Impl/Record_busbar_tempServiceImpl.cs create mode 100644 SlnMesnac.Repository/service/Impl/Record_inspection_cabinetServiceImpl.cs diff --git a/SlnMesnac.Business/AutoTaskBusiness.cs b/SlnMesnac.Business/AutoModeBusiness.cs similarity index 58% rename from SlnMesnac.Business/AutoTaskBusiness.cs rename to SlnMesnac.Business/AutoModeBusiness.cs index 23b9588..98fd4b2 100644 --- a/SlnMesnac.Business/AutoTaskBusiness.cs +++ b/SlnMesnac.Business/AutoModeBusiness.cs @@ -1,4 +1,6 @@ -using SlnMesnac.Business.@base; +using Microsoft.IdentityModel.Logging; +using SlnMesnac.Business.@base; +using SlnMesnac.Config; using SlnMesnac.Model.dto; using SlnMesnac.Plc; using SlnMesnac.Repository; @@ -34,18 +36,70 @@ using System.Threading.Tasks; #endregion << 版 本 注 释 >> namespace SlnMesnac.Business { - public class AutoTaskBusiness : BaseBusiness + /// + /// 自动模式 + /// + public class AutoModeBusiness : BaseBusiness { public readonly RealTemperatureInfo _realTemperatureInfo = new RealTemperatureInfo(); - public AutoTaskBusiness(SerilogHelper log,PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices, Ibase_busbar_infoServices base_Busbar_InfoServices) : base(log,plc, base_Cabinet_InfoServices, base_Busbar_InfoServices) + private readonly Irecord_busbar_tempServices _record_busbar_TempServices; + + private readonly AppConfig _appConfig; + + private System.Timers.Timer timer = null; + + public delegate void CaptureAlarmPicture(string sJpegPicFileName); + public event CaptureAlarmPicture CaptureAlarmPictureEvent; + + public AutoModeBusiness(SerilogHelper log, PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices, Ibase_busbar_infoServices base_Busbar_InfoServices, Irecord_busbar_tempServices record_busbar_TempServices, AppConfig appConfig) : base(log, plc, base_Cabinet_InfoServices, base_Busbar_InfoServices) { + _record_busbar_TempServices = record_busbar_TempServices; + _appConfig = appConfig; + + + } + + public void Start() + { + try + { + timer = new System.Timers.Timer(1000 * 60 * _appConfig.checkCycle); + timer.Elapsed += new System.Timers.ElapsedEventHandler(AutoModelEvent); + timer.AutoReset = true; + timer.Enabled = false; + timer.Start(); + _log.Info($"自动模式初始化成功"); + this.AutoModelEvent(null, null); + } + catch (Exception ex) + { + _log.Info($"自动模式初始化异常:{ex.Message}"); + } + } + + public void Stop() + { + try + { + if (timer.Enabled) + { + timer.Stop(); + timer.Close(); + timer.Dispose(); + _log.Info($"自动模式关闭成功"); + } + } + catch (Exception ex) + { + _log.Info($"自动模式停止异常:{ex.Message}"); + } } /// /// 自动巡检 /// - public void AutoCheckHandle() + private void AutoModelEvent(object source, System.Timers.ElapsedEventArgs e) { lock(string.Empty) { @@ -84,9 +138,9 @@ namespace SlnMesnac.Business _log.Info($"巡检结束"); }); - }catch (Exception e) + }catch (Exception ex) { - throw new InvalidOperationException($"自动巡检逻辑处理异常:{e.Message}"); + throw new InvalidOperationException($"自动巡检逻辑处理异常:{ex.Message}"); } } @@ -134,9 +188,9 @@ namespace SlnMesnac.Business //这里采集数据 _log.Info($"5S后开始测温"); Task.Delay(5000).Wait(); - _log.Info($"最高温度:{_realTemperatureInfo.fMaxTemperature};最低温度:{_realTemperatureInfo.fMinTemperature};平均温度:{_realTemperatureInfo.fAverageTemperature};温差:{_realTemperatureInfo.fTemperatureDiff}"); + _log.Info($"温度测量完成,最高温度:{_realTemperatureInfo.fMaxTemperature};最低温度:{_realTemperatureInfo.fMinTemperature};平均温度:{_realTemperatureInfo.fAverageTemperature};温差:{_realTemperatureInfo.fTemperatureDiff}"); + this.SaveBusbarTemp(busbar.busbarCode, busbar.cabinetCode, _realTemperatureInfo); Task.Delay(1000).Wait(); - _log.Info($"温度测量完成"); } } @@ -177,5 +231,50 @@ namespace SlnMesnac.Business } } + /// + /// 保存母排测温数据 + /// + /// + /// + /// + private void SaveBusbarTemp(int? busbarCode, int? cabinetCode,RealTemperatureInfo realTemperatureInfo) + { + try + { + + var record = new record_busbar_temp() + { + busbarCode = busbarCode, + cabinetCode = cabinetCode, + tempMax = (decimal)realTemperatureInfo.fMaxTemperature, + tempMin = (decimal)realTemperatureInfo.fMinTemperature, + tempAvg = (decimal)realTemperatureInfo.fAverageTemperature, + tempDiff = (decimal)realTemperatureInfo.fTemperatureDiff, + recordTime = DateTime.Now, + }; + + if (realTemperatureInfo.fMaxTemperature > 65) + { + record.isAlarm = 1; + string sJpegPicFileName = $"{cabinetCode}_{busbarCode}_{DateTime.Now.ToString("yyyyMMddHHmmssffff")}.jpg"; + record.filePath = sJpegPicFileName ; + CaptureAlarmPictureEvent?.Invoke(sJpegPicFileName); + } + var res = _record_busbar_TempServices.Insert(record); + + if (res) + { + _log.Info($"{cabinetCode}号电柜{busbarCode}排数据保存成功"); + } + else + { + _log.Info($"{cabinetCode}号电柜{busbarCode}排数据保存失败"); + } + }catch(Exception e) + { + _log.Info($"{cabinetCode}号电柜{busbarCode}排数据保存异常:{e.Message}"); + } + } + } } diff --git a/SlnMesnac.Business/InspModeBusiness.cs b/SlnMesnac.Business/InspModeBusiness.cs new file mode 100644 index 0000000..afe8aca --- /dev/null +++ b/SlnMesnac.Business/InspModeBusiness.cs @@ -0,0 +1,59 @@ +using SlnMesnac.Business.@base; +using SlnMesnac.Plc; +using SlnMesnac.Repository; +using SlnMesnac.Repository.service; +using SlnMesnac.Serilog; +using System; +using System.Collections.Generic; +using System.Text; + +#region << 版 本 注 释 >> +/*-------------------------------------------------------------------- +* 版权所有 (c) 2024 WenJY 保留所有权利。 +* CLR版本:4.0.30319.42000 +* 机器名称:T14-GEN3-7895 +* 命名空间:SlnMesnac.Business +* 唯一标识:73cd3d99-8387-4ff6-9276-8eeb424e2aa2 +* +* 创建者:WenJY +* 电子邮箱: +* 创建时间:2024-11-07 9:51:55 +* 版本:V1.0.0 +* 描述: +* +*-------------------------------------------------------------------- +* 修改人: +* 时间: +* 修改说明: +* +* 版本:V1.0.0 +*--------------------------------------------------------------------*/ +#endregion << 版 本 注 释 >> +namespace SlnMesnac.Business +{ + /// + /// Inspection mode 巡检模式 + /// + public class InspModeBusiness : BaseBusiness + { + private readonly Irecord_inspection_cabinetServices _service; + public InspModeBusiness(SerilogHelper log, PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices, Ibase_busbar_infoServices base_Busbar_InfoServices, Irecord_inspection_cabinetServices service) : base(log, plc, base_Cabinet_InfoServices, base_Busbar_InfoServices) + { + _service = service; + } + + public void Start(string taskCode,string filePath) + { + record_inspection_cabinet record_Inspection = new record_inspection_cabinet(); + record_Inspection.taskCode = taskCode; + record_Inspection.filePath = filePath; + record_Inspection.beginTime = DateTime.Now; + _service.Insert(record_Inspection); + } + + public void Stop(string taskCode, string filePath) + { + + } + } +} diff --git a/SlnMesnac.Business/ManualModeBusiness.cs b/SlnMesnac.Business/ManualModeBusiness.cs new file mode 100644 index 0000000..167bd8a --- /dev/null +++ b/SlnMesnac.Business/ManualModeBusiness.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Text; + +#region << 版 本 注 释 >> +/*-------------------------------------------------------------------- +* 版权所有 (c) 2024 WenJY 保留所有权利。 +* CLR版本:4.0.30319.42000 +* 机器名称:T14-GEN3-7895 +* 命名空间:SlnMesnac.Business +* 唯一标识:04146a2b-c51d-4164-8c51-158a99301078 +* +* 创建者:WenJY +* 电子邮箱: +* 创建时间:2024-11-07 9:52:46 +* 版本:V1.0.0 +* 描述: +* +*-------------------------------------------------------------------- +* 修改人: +* 时间: +* 修改说明: +* +* 版本:V1.0.0 +*--------------------------------------------------------------------*/ +#endregion << 版 本 注 释 >> +namespace SlnMesnac.Business +{ + /// + /// 手动模式 + /// + internal class ManualModeBusiness + { + } +} diff --git a/SlnMesnac.Business/base/BaseBusiness.cs b/SlnMesnac.Business/base/BaseBusiness.cs index 684c1c9..17ebc56 100644 --- a/SlnMesnac.Business/base/BaseBusiness.cs +++ b/SlnMesnac.Business/base/BaseBusiness.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Net; +using System.Threading.Tasks; #region << 版 本 注 释 >> /*-------------------------------------------------------------------- @@ -55,7 +56,7 @@ namespace SlnMesnac.Business.@base /// /// 工作模式:1-自动;2-巡检;3-手动 /// - public void InitEquip(int model) + public async void InitEquip(int model) { try { @@ -66,6 +67,7 @@ namespace SlnMesnac.Business.@base if (plcFlag != 1) { _log.Info($"PLC状态不具备启动条件:VD1509值为{plcFlag}"); + Task.Delay(1000).Wait(); continue; } diff --git a/SlnMesnac.Config/AppConfig.cs b/SlnMesnac.Config/AppConfig.cs index 4edd9eb..23d4665 100644 --- a/SlnMesnac.Config/AppConfig.cs +++ b/SlnMesnac.Config/AppConfig.cs @@ -52,6 +52,11 @@ namespace SlnMesnac.Config /// public string videoFilePath { get; set; } + /// + /// 巡检周期 + /// + public int checkCycle { get; set; } + /// /// Sql连接配置 /// diff --git a/SlnMesnac.Generate/Templates/Service/Impl/Services.vm b/SlnMesnac.Generate/Templates/Service/Impl/Services.vm index bcf9a49..e6c2367 100644 --- a/SlnMesnac.Generate/Templates/Service/Impl/Services.vm +++ b/SlnMesnac.Generate/Templates/Service/Impl/Services.vm @@ -5,7 +5,7 @@ using System.Collections.Generic; namespace ${NameSpace}.service.Impl { - public class ${tableName}ServiceImpl : BaseServiceImpl<${tableName}>, I${tableName}Service + public class ${tableName}ServiceImpl : BaseServiceImpl<${tableName}>, I${tableName}Services { public ${tableName}ServiceImpl(Repository<${tableName}> repository):base(repository) { diff --git a/SlnMesnac.Model/domain/record_busbar_temp.cs b/SlnMesnac.Model/domain/record_busbar_temp.cs new file mode 100644 index 0000000..8925612 --- /dev/null +++ b/SlnMesnac.Model/domain/record_busbar_temp.cs @@ -0,0 +1,145 @@ +using System; +using System.Linq; +using System.Text; +using SqlSugar; + +namespace SlnMesnac.Repository +{ + /// + ///母排测温信息 + /// + [SugarTable("record_busbar_temp"), TenantAttribute("iot")] + public partial class record_busbar_temp + { + public record_busbar_temp(){ + + + } + /// + /// Desc:标识 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey=true,IsIdentity=true,ColumnName="objId")] + public int objid {get;set;} + + /// + /// Desc:母排编号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="busbar_code")] + public int? busbarCode {get;set;} + + /// + /// Desc:电柜编号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="cabinet_code")] + public int? cabinetCode {get;set;} + + /// + /// Desc:最高温度 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="temp_max")] + public decimal? tempMax {get;set;} + + /// + /// Desc:最低温度 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="temp_min")] + public decimal? tempMin {get;set;} + + /// + /// Desc:平均温度 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="temp_avg")] + public decimal? tempAvg {get;set;} + + /// + /// Desc:温差 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="temp_diff")] + public decimal? tempDiff {get;set;} + + /// + /// Desc:是否告警:1-是;0-否 + /// Default:0 + /// Nullable:True + /// + [SugarColumn(ColumnName="is_alarm")] + public int? isAlarm {get;set;} + + /// + /// Desc:图像路径 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="file_path")] + public string filePath {get;set;} + + /// + /// Desc:是否启用:1-是;0-否 + /// Default:0 + /// Nullable:True + /// + [SugarColumn(ColumnName="is_flag")] + public int? isFlag {get;set;} + + /// + /// Desc:备注 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="remark")] + public string remark {get;set; } + + /// + /// 记录时间 + /// + [SugarColumn(ColumnName = "record_time")] + public DateTime? recordTime { get; set; } + + /// + /// Desc:创建人 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="created_by")] + public string createdBy {get;set;} + + /// + /// Desc:创建时间 + /// Default:CURRENT_TIMESTAMP + /// Nullable:True + /// + [SugarColumn(ColumnName="created_time")] + public DateTime? createdTime {get;set;} + + /// + /// Desc:更新人 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="updated_by")] + public string updatedBy {get;set;} + + /// + /// Desc:更新时间 + /// Default:CURRENT_TIMESTAMP + /// Nullable:True + /// + [SugarColumn(ColumnName="updated_time")] + public DateTime? updatedTime {get;set;} + + } +} diff --git a/SlnMesnac.Model/domain/record_inspection_cabinet.cs b/SlnMesnac.Model/domain/record_inspection_cabinet.cs new file mode 100644 index 0000000..a2de4d9 --- /dev/null +++ b/SlnMesnac.Model/domain/record_inspection_cabinet.cs @@ -0,0 +1,91 @@ +using System; +using System.Linq; +using System.Text; +using SqlSugar; + +namespace SlnMesnac.Repository +{ + /// + ///电柜巡检记录 + /// + [SugarTable("record_inspection_cabinet"), TenantAttribute("iot")] + public partial class record_inspection_cabinet + { + public record_inspection_cabinet(){ + + + } + /// + /// Desc:标识 + /// Default: + /// Nullable:True + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "obj_id")] + public int? objId {get;set;} + + /// + /// Desc:任务编号 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="task_code")] + public string taskCode {get;set;} + + /// + /// Desc:开始时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="begin_time")] + public DateTime? beginTime {get;set;} + + /// + /// Desc:结束时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="end_time")] + public DateTime? endTime {get;set;} + + /// + /// Desc:文件路径 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="file_path")] + public string filePath {get;set;} + + /// + /// Desc:创建人 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="created_by")] + public string createdBy {get;set;} + + /// + /// Desc:创建时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="created_time")] + public DateTime? createdTime {get;set;} + + /// + /// Desc:更新人 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="updated_by")] + public string updatedBy {get;set;} + + /// + /// Desc:更新时间 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName="updated_time")] + public DateTime? updatedTime {get;set;} + + } +} diff --git a/SlnMesnac.Repository/service/IRecord_busbar_tempService.cs b/SlnMesnac.Repository/service/IRecord_busbar_tempService.cs new file mode 100644 index 0000000..b393ff0 --- /dev/null +++ b/SlnMesnac.Repository/service/IRecord_busbar_tempService.cs @@ -0,0 +1,13 @@ +using SlnMesnac.Model.domain; +using SlnMesnac.Repository.service.@base; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Repository.service +{ + public interface Irecord_busbar_tempServices: IBaseService + { + + } +} \ No newline at end of file diff --git a/SlnMesnac.Repository/service/IRecord_inspection_cabinetService.cs b/SlnMesnac.Repository/service/IRecord_inspection_cabinetService.cs new file mode 100644 index 0000000..3e741ce --- /dev/null +++ b/SlnMesnac.Repository/service/IRecord_inspection_cabinetService.cs @@ -0,0 +1,13 @@ +using SlnMesnac.Model.domain; +using SlnMesnac.Repository.service.@base; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Repository.service +{ + public interface Irecord_inspection_cabinetServices: IBaseService + { + + } +} \ No newline at end of file diff --git a/SlnMesnac.Repository/service/Impl/Record_busbar_tempServiceImpl.cs b/SlnMesnac.Repository/service/Impl/Record_busbar_tempServiceImpl.cs new file mode 100644 index 0000000..918f4b8 --- /dev/null +++ b/SlnMesnac.Repository/service/Impl/Record_busbar_tempServiceImpl.cs @@ -0,0 +1,14 @@ +using SlnMesnac.Model.domain; +using SlnMesnac.Repository.service.@base; +using System; +using System.Collections.Generic; + +namespace SlnMesnac.Repository.service.Impl +{ + public class record_busbar_tempServiceImpl : BaseServiceImpl, Irecord_busbar_tempServices + { + public record_busbar_tempServiceImpl(Repository repository):base(repository) + { + } + } +} \ No newline at end of file diff --git a/SlnMesnac.Repository/service/Impl/Record_inspection_cabinetServiceImpl.cs b/SlnMesnac.Repository/service/Impl/Record_inspection_cabinetServiceImpl.cs new file mode 100644 index 0000000..de8e83e --- /dev/null +++ b/SlnMesnac.Repository/service/Impl/Record_inspection_cabinetServiceImpl.cs @@ -0,0 +1,14 @@ +using SlnMesnac.Model.domain; +using SlnMesnac.Repository.service.@base; +using System; +using System.Collections.Generic; + +namespace SlnMesnac.Repository.service.Impl +{ + public class record_inspection_cabinetServiceImpl : BaseServiceImpl, Irecord_inspection_cabinetServices + { + public record_inspection_cabinetServiceImpl(Repository repository):base(repository) + { + } + } +} \ No newline at end of file diff --git a/SlnMesnac.WPF/Page/IndexControl.xaml b/SlnMesnac.WPF/Page/IndexControl.xaml index d7567fe..0ccba6d 100644 --- a/SlnMesnac.WPF/Page/IndexControl.xaml +++ b/SlnMesnac.WPF/Page/IndexControl.xaml @@ -38,7 +38,7 @@ - + @@ -47,7 +47,7 @@ - + @@ -115,8 +115,12 @@ - -