From d14b2ac45fddf5f55d4d5c5e029dfafcba1e1ad9 Mon Sep 17 00:00:00 2001 From: gongxh Date: Tue, 17 May 2022 09:25:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CleanMachine.BLL/CM/DayWorkTimeBLL.cs | 12 +-- CleanMachine.DAL/CM/DayWorkTimeDAL.cs | 12 +-- CleanMachine.Model/CM/DayWorkTime.cs | 2 + CleanMachineHMI/CleanMachineHMI.csproj | 6 -- CleanMachineHMI/DataBase/clearMac.db | Bin 380928 -> 380928 bytes .../FrmUserControl/frmMainDetail.cs | 34 ++++----- .../FrmUserControl/frmMainDetailNew.cs | 35 ++++----- CleanMachineHMI/FrmUserControl/frmManual.cs | 72 +++++++++--------- .../FrmUserControl/frmMechineCheck.cs | 6 +- .../FrmUserControl/frmPlcAlarmLog.cs | 2 +- CleanMachineHMI/Utils/GlobalHelper.cs | 2 +- CleanMachineHMI/Utils/PlcOperationHelper.cs | 10 +-- .../frmChild/frmSwitchRunDirection.cs | 2 +- CleanMachineHMI/frmMainNew.cs | 44 +++++++---- 14 files changed, 125 insertions(+), 114 deletions(-) diff --git a/CleanMachine.BLL/CM/DayWorkTimeBLL.cs b/CleanMachine.BLL/CM/DayWorkTimeBLL.cs index 3a48c53..f920570 100644 --- a/CleanMachine.BLL/CM/DayWorkTimeBLL.cs +++ b/CleanMachine.BLL/CM/DayWorkTimeBLL.cs @@ -15,22 +15,22 @@ namespace CleanMachine.BLL.CM /// /// 存在 /// - public bool Exists(DateTime Date) + public bool Exists(DateTime Date,string UserName) { - return new DayWorkTimeDAL().Exists(Date); + return new DayWorkTimeDAL().Exists(Date, UserName); } - public bool UpdateTime(DateTime date, int value) + public bool UpdateTime(DateTime date, int value,string UserName) { var _dal = new DayWorkTimeDAL(); - if (!_dal.Exists(date)) + if (!_dal.Exists(date,UserName)) { - return _dal.Add(new Model.CM.DayWorkTime() { Date = date, StartValue = value, StartTime = DateTime.Now, EndValue = 0 }); + return _dal.Add(new Model.CM.DayWorkTime() {UserName=UserName ,Date = date, StartValue = value, StartTime = DateTime.Now, EndValue = 0 }); } else { - return _dal.UpdateEndValue(new Model.CM.DayWorkTime() { Date = date, StartValue = 0, EndValue = value, EndTime = DateTime.Now }); + return _dal.UpdateEndValue(new Model.CM.DayWorkTime() {UserName=UserName ,Date = date, StartValue = 0, EndValue = value, EndTime = DateTime.Now }); } } diff --git a/CleanMachine.DAL/CM/DayWorkTimeDAL.cs b/CleanMachine.DAL/CM/DayWorkTimeDAL.cs index 93a817f..c5d5cf0 100644 --- a/CleanMachine.DAL/CM/DayWorkTimeDAL.cs +++ b/CleanMachine.DAL/CM/DayWorkTimeDAL.cs @@ -16,10 +16,10 @@ namespace CleanMachine.DAL.CM /// /// 存在 /// - public bool Exists(DateTime Date) + public bool Exists(DateTime Date,string UserName) { - string strSql = @"SELECT count(1) from CM_DayWorkTime WHERE Date=@Date "; - return LeadDbHelperSQLite.ExecuteScalar(strSql, new { Date }) > 0; + string strSql = @"SELECT count(1) from CM_DayWorkTime WHERE Date=@Date and UserName=@UserName "; + return LeadDbHelperSQLite.ExecuteScalar(strSql, new { Date, UserName }) > 0; } /// @@ -28,9 +28,9 @@ namespace CleanMachine.DAL.CM public bool Add(CleanMachine.Model.CM.DayWorkTime model) { string strSql = $@"INSERT INTO CM_DayWorkTime - (Date,StartValue,EndValue,StartTime) + (Date,StartValue,EndValue,StartTime,UserName) values - (@Date,@StartValue,@EndValue,@StartTime) "; + (@Date,@StartValue,@EndValue,@StartTime,@UserName) "; return LeadDbHelperSQLite.Execute(strSql, model) > 0; } @@ -41,7 +41,7 @@ namespace CleanMachine.DAL.CM { string strSql = $@"UPDATE CM_DayWorkTime SET StartValue=@StartValue,EndValue=@EndValue - WHERE Date=@Date "; + WHERE Date=@Date and UserName=@UserName "; return LeadDbHelperSQLite.Execute(strSql, model) > 0; } diff --git a/CleanMachine.Model/CM/DayWorkTime.cs b/CleanMachine.Model/CM/DayWorkTime.cs index 2fbea12..4f4e0cf 100644 --- a/CleanMachine.Model/CM/DayWorkTime.cs +++ b/CleanMachine.Model/CM/DayWorkTime.cs @@ -14,6 +14,7 @@ namespace CleanMachine.Model.CM private DateTime _startTime; private DateTime _endTime; + private string _userName; /// /// @@ -44,5 +45,6 @@ namespace CleanMachine.Model.CM public DateTime StartTime { get => _startTime; set => _startTime = value; } public DateTime EndTime { get => _endTime; set => _endTime = value; } + public string UserName { get => _userName; set => _userName = value; } } } diff --git a/CleanMachineHMI/CleanMachineHMI.csproj b/CleanMachineHMI/CleanMachineHMI.csproj index 97e2399..f2191da 100644 --- a/CleanMachineHMI/CleanMachineHMI.csproj +++ b/CleanMachineHMI/CleanMachineHMI.csproj @@ -36,12 +36,6 @@ - - ..\public\ComponentFactory.Krypton.Navigator.dll - - - ..\public\ComponentFactory.Krypton.Toolkit.dll - ..\public\FastReport.dll diff --git a/CleanMachineHMI/DataBase/clearMac.db b/CleanMachineHMI/DataBase/clearMac.db index a7802882738a0ec711a2c71305601a6f0120775e..84d20a683d6450aed337045cb0052b1f5e6290d9 100644 GIT binary patch delta 420 zcmX|*KS/{3z{u78-KnU6e*&1X&0%|3=@$uA`qE#d{adC2$nXa zB2E0$#+f$n%g9%95$S5lo`8_r_^XKH3cjngOTZk%4>CX;qBS*5J&~W&WlE%%l1?s2 zZt%BvNUkevp|8Bu^~W_jfXHm|y1H1Q_RPh42R#N?*2rn0#?6xgTCyZ70CjYMCh z#01}W;dn9L#Gb56>4daCd7B=efiU8Y??WhISvZ1`9lMvnBpT% zl=bkdkJ%6D%tn@Pw_)*G3q!$h%zmuHj^A*K9UOL~(}RY2I8MzYJ5No|*BVr{A#?4X phOi-?+|yYMlGV?QM5E9#JQ57>FFhK^I7f;`x7;2TZcl!C`ws)4eL4UD delta 312 zcmWlSJxIeq0EO@6VlJtTO)Vuzke*6ugCd9^TBm|INO5rMAXKQEvx6P{gSr|Vf|IF( zPDM+l=jh_rA$D@A#Vz2_Od^UHhws7TgZGX+^T;#Ltz?%FvK>Jq;t`=Uw}@`5Qcoyb zQMF3#kA!7l^i<_S<@h;_fdzyGETDl?G)2}!7Hy9=B*;#2Qljr|hxe%nZegj$2%6EV zwxf7*3QfHnxl4%BBOaL8Xy8ieJORc`bTmc+qNn4vctMlY7gc3<@)9jmBCSgr3DCW8 z_;c*IQe~!XVzY%`r9QyTK)M&) zql3(Ua^u=JIzD9_)K!NxgFTTS(lzMSeUs#J(2z /// 用户信息 /// - public static UserInfo UserInfo { get; set; } + public static UserInfo UserInfo { get; set; }=null; /// /// 参数列表 diff --git a/CleanMachineHMI/Utils/PlcOperationHelper.cs b/CleanMachineHMI/Utils/PlcOperationHelper.cs index 11160ad..bb68d48 100644 --- a/CleanMachineHMI/Utils/PlcOperationHelper.cs +++ b/CleanMachineHMI/Utils/PlcOperationHelper.cs @@ -117,7 +117,7 @@ namespace CleanMachineHMI private bool _isConn = false; - public bool isConn + public bool IsConn { get { @@ -264,7 +264,7 @@ namespace CleanMachineHMI catch (Exception ex) { LogHelper.WriteLog($"初始化PLC连接时发生异常:【{ex.Message}】", LogTypeEum.Err); - isConn = false; + IsConn = false; return false; } } @@ -318,7 +318,7 @@ namespace CleanMachineHMI { port.Close(); master = null; - isConn = false; + IsConn = false; } } public void RefreshPlcItem_M(ref bool haschange) @@ -1191,7 +1191,7 @@ namespace CleanMachineHMI } if (WritePlcItem("PlcHeartbeatWriteData", wcsToPlcHeartData.ToString(), PlcItemTypeDesc.D)) { - isConn = true; + IsConn = true; HeartbeatTime = DateTime.Now; wcsToPlcHeartDataNew = wcsToPlcHeartData; frmMainNew.Show_Plc_Alarm("Serial port open success, PLC connect success!"); @@ -1212,7 +1212,7 @@ namespace CleanMachineHMI } if (WritePlcItem("PlcHeartbeatWriteData", wcsToPlcHeartData.ToString(), PlcItemTypeDesc.D)) { - isConn = true; + IsConn = true; HeartbeatTime = DateTime.Now; wcsToPlcHeartDataNew = wcsToPlcHeartData; frmMainNew.Show_Plc_Alarm("Serial port open success, PLC connect success!"); diff --git a/CleanMachineHMI/frmChild/frmSwitchRunDirection.cs b/CleanMachineHMI/frmChild/frmSwitchRunDirection.cs index 6e71a97..38725f3 100644 --- a/CleanMachineHMI/frmChild/frmSwitchRunDirection.cs +++ b/CleanMachineHMI/frmChild/frmSwitchRunDirection.cs @@ -82,7 +82,7 @@ namespace CleanMachineHMI.frmChild KryptonMessageBox.Show(this.T("请选择切换方向!", "SelectSwitchDirectionInfo")); return; } - if (!PlcOperationHelper.Instance.isConn) + if (!PlcOperationHelper.Instance.IsConn) { KryptonMessageBox.Show("The PLC is disconnected and unable to operate the equipment."); return; diff --git a/CleanMachineHMI/frmMainNew.cs b/CleanMachineHMI/frmMainNew.cs index 06aca31..7355fc4 100644 --- a/CleanMachineHMI/frmMainNew.cs +++ b/CleanMachineHMI/frmMainNew.cs @@ -28,6 +28,13 @@ namespace CleanMachineHMI public frmMainNew() { InitializeComponent(); + //清理过期任务 + string sqlZbkWorkingPallet = $@"DELETE FROM ZBK_WORKING_PALLET WHERE julianday('now') - julianday(UPDATE_TIME) > 30"; + string sqlZbkWorkingPalletDtl = $@"DELETE FROM ZBK_WORKING_PALLET_DTL WHERE julianday('now') - julianday(UPDATE_TIME) > 30"; + LeadDbHelperSQLite.Execute(sqlZbkWorkingPallet); + LeadDbHelperSQLite.Execute(sqlZbkWorkingPalletDtl); + + } #region 全局变量 @@ -241,6 +248,7 @@ namespace CleanMachineHMI isPlcConnStatus = true; Global.SysThIsRunFlag = true; + PlcOperationHelper.Instance.StartRead(); @@ -592,21 +600,27 @@ namespace CleanMachineHMI } } - - int SysRunTime = (int)PlcOperationHelper.Instance.ReadPlcItem("SysRuningTime", PlcItemTypeDesc.D); - - new CleanMachine.BLL.CM.DayWorkTimeBLL().UpdateTime(DateTime.Today, SysRunTime); - - - int Minutes = (SysRunTime - CleanMachineHMI.Global.MaintainTime) / 60; - BeginInvoke(new Action(() => + if (Global.UserInfo != null) { - kryptonLabel1.Text = Minutes + " Minutes"; - pictureBox1.Visible = Minutes >= Global.MaintainAlarmTime; + int SysRunTime = (int)PlcOperationHelper.Instance.ReadPlcItem("SysRuningTime", PlcItemTypeDesc.D); + + if (SysRunTime != 0) + { + new CleanMachine.BLL.CM.DayWorkTimeBLL().UpdateTime(DateTime.Today, SysRunTime, Global.UserInfo.UserName); - })); + int Minutes = (SysRunTime - CleanMachineHMI.Global.MaintainTime) / 60; + BeginInvoke(new Action(() => + { + + kryptonLabel1.Text = Minutes + " Minutes"; + pictureBox1.Visible = Minutes >= Global.MaintainAlarmTime; + + + })); + } + } //string sqlParam = $@"SELECT * FROM SYS_PARAMETER"; @@ -719,10 +733,10 @@ namespace CleanMachineHMI #region 定期清理历史业务数据 -- 数据保存2个月 - string sqlZbkWorkingPallet = $@"DELETE FROM ZBK_WORKING_PALLET WHERE julianday('now') - julianday(UPDATE_TIME) > 30"; - string sqlZbkWorkingPalletDtl = $@"DELETE FROM ZBK_WORKING_PALLET_DTL WHERE julianday('now') - julianday(UPDATE_TIME) > 30"; - LeadDbHelperSQLite.Execute(sqlZbkWorkingPallet); - LeadDbHelperSQLite.Execute(sqlZbkWorkingPalletDtl); + //string sqlZbkWorkingPallet = $@"DELETE FROM ZBK_WORKING_PALLET WHERE julianday('now') - julianday(UPDATE_TIME) > 30"; + //string sqlZbkWorkingPalletDtl = $@"DELETE FROM ZBK_WORKING_PALLET_DTL WHERE julianday('now') - julianday(UPDATE_TIME) > 30"; + //LeadDbHelperSQLite.Execute(sqlZbkWorkingPallet); + //LeadDbHelperSQLite.Execute(sqlZbkWorkingPalletDtl); #endregion // PlcOperationHelper.Instance.HeartbeatDetection();