diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjMaterial/DBHelp.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjMaterial/DBHelp.cs index 5450c51..1342e8a 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjMaterial/DBHelp.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjMaterial/DBHelp.cs @@ -13,7 +13,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjMaterial { return new Dictionary(); } - + public static DataTable GetTable(string sql) { DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); @@ -59,7 +59,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjMaterial dbHelper.CommandText = insertUserSql; foreach (var keyValuePair in dic) { - dbHelper.AddParameter(keyValuePair.Key,keyValuePair.Value); + dbHelper.AddParameter(keyValuePair.Key, keyValuePair.Value); } DataTable table = dbHelper.ToDataTable(); return table; @@ -67,8 +67,9 @@ namespace Mesnac.Action.ChemicalWeighing.LjMaterial public static void ExecuteNonQuery(string sql) { - ExecuteNonQuery(sql,new Dictionary()); + ExecuteNonQuery(sql, new Dictionary()); } + public static void ExecuteNonQuery(string sql, IDictionary dic) { DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); @@ -83,11 +84,11 @@ namespace Mesnac.Action.ChemicalWeighing.LjMaterial dbHelper.CommandText = insertUserSql; foreach (var keyValuePair in dic) { - dbHelper.AddParameter(keyValuePair.Key,keyValuePair.Value); + dbHelper.AddParameter(keyValuePair.Key, keyValuePair.Value); } - + dbHelper.ExecuteNonQuery(); - } - + } + } } \ No newline at end of file diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/LjLogControl.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/LjLogControl.cs index 2bf4839..db56437 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/LjLogControl.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/LjLogControl.cs @@ -62,6 +62,21 @@ namespace Mesnac.Action.ChemicalWeighing.Report return DBHelp.GetTable(sql); } + /// + /// 去年数据的转移 + /// + public static void LastYearDataCut() + { + int nowYear = DateTime.Now.Year; + string sql = $"insert into Manual_Log_{nowYear - 1} " + + $"select logtext, logtime, userid, value, valuekind, deviceno, devicekind, createdate " + + $"from Manual_Log where logtime < '{nowYear}-01-01 00:00:00'"; + DBHelp.ExecuteNonQuery(sql); + sql = $"delete from Manual_Log where logtime < '{nowYear}-01-01 00:00:00'"; + DBHelp.ExecuteNonQuery(sql); + + } + private static string BaseSelect(string sql) { string s = "select top 500 id, logtext, logtime, value, deviceno from Manual_Log " + sql + diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/LjLogReport.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/LjLogReport.cs index da9f1a0..27169b9 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/LjLogReport.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/LjLogReport.cs @@ -32,6 +32,7 @@ namespace Mesnac.Action.ChemicalWeighing.Report MCButton ManualControl; MCButton Refresh; MCButton SelectByText; + MCButton LastYearDataMove; //HslSwitch HslSwitch1; //HslSwitch HslSwitch2; @@ -63,6 +64,7 @@ namespace Mesnac.Action.ChemicalWeighing.Report ManualControl = control.FirstOrDefault(x => x != null && x.Name == "ManualControl") as MCButton; Refresh = control.FirstOrDefault(x => x != null && x.Name == "Refresh") as MCButton; SelectByText = control.FirstOrDefault(x => x != null && x.Name == "SelectByText") as MCButton; + LastYearDataMove = control.FirstOrDefault(x => x != null && x.Name == "LastYearDataMove") as MCButton; StartDate = control.FirstOrDefault(x => x != null && x.Name == "StartDate") as MCDateTimePicker; EndDate = control.FirstOrDefault(x => x != null && x.Name == "EndDate") as MCDateTimePicker; LogForm = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "ManualLogGridView1").FirstOrDefault(); @@ -109,66 +111,21 @@ namespace Mesnac.Action.ChemicalWeighing.Report ManualControl.Click += ManualControlSelect; Refresh.Click += RefreshAction; SelectByText.Click += SelectByTextAction; + LastYearDataMove.Click += DataMoveAction; } /// - /// 下发送料请求按钮点击 + /// 转移去年的数据 /// /// /// - private void RequestDownloadClick(object sender, EventArgs e) + private void DataMoveAction(object sender, EventArgs e) { - bool mixok1 = PlcConnect.Instance.ReadBool("DB3000.0.0").Content; - Time(1, mixok1 ? 1 : 0); - bool mixok2 = PlcConnect.Instance.ReadBool("DB3000.0.1").Content; - Time(2, mixok2 ? 1 : 0); - bool mixok3 = PlcConnect.Instance.ReadBool("DB3000.0.2").Content; - Time(3, mixok3 ? 1 : 0); - bool mixok4 = PlcConnect.Instance.ReadBool("DB3000.0.3").Content; - Time(4, mixok4 ? 1 : 0); - bool mixok5 = PlcConnect.Instance.ReadBool("DB3000.0.4").Content; - Time(5, mixok5 ? 1 : 0); - bool mixok6 = PlcConnect.Instance.ReadBool("DB3000.0.5").Content; - Time(6, mixok6 ? 1 : 0); - bool mixok7 = PlcConnect.Instance.ReadBool("DB3000.0.6").Content; - Trace.WriteLine("7号信号:" + mixok7); - Time(7, mixok7 ? 1 : 0); - bool mixok8 = PlcConnect.Instance.ReadBool("DB3000.0.7").Content; - Trace.WriteLine("8号信号:" + mixok8); - Time(8, mixok8 ? 1 : 0); - } - - /// - /// 下发接料请求 - /// - /// - /// - private void Time(int deviceNo, int statu) - { - TankIsDischargedSyncEntity tankIsDischargedSyncEntity = new TankIsDischargedSyncEntity() - { - reqCode = System.Guid.NewGuid().ToString(), - reqTime = DateTime.Now, - deviceNo = deviceNo.ToString(), - state = statu.ToString(), - }; - //即使网络不同 也不会影响上位机的使用 - ThreadPool.QueueUserWorkItem(delegate - { - HttpResponse httpResponse = new HttpResponse(); - string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity); - MesnacServiceManager.Instance.LoggingService.Info($"湿混机{deviceNo}返回数据" + returnTest); - }); - } - - /// - /// 消除报警按钮点击 - /// - /// - /// - private void EliAlarmsClick(object sender, EventArgs e) - { - + if (MessageBox.Show("确认要切割数据?", "三次提醒 3/1", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } + if (MessageBox.Show("确认要切割数据?", "三次提醒 3/2", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } + if (MessageBox.Show("确认要切割数据?", "三次提醒 3/3", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } + LjLogControl.LastYearDataCut(); + MessageBox.Show("数据切割成功"); } /// diff --git a/Main/MCEdit/Data/MCProject/nodeForm/LjLogForm.xml b/Main/MCEdit/Data/MCProject/nodeForm/LjLogForm.xml index adf0591..bf27a87 100644 --- a/Main/MCEdit/Data/MCProject/nodeForm/LjLogForm.xml +++ b/Main/MCEdit/Data/MCProject/nodeForm/LjLogForm.xml @@ -1,5 +1,70 @@ + + + + + Red + DarkGray + + + False + + + + None + True + True + 每年年初点击 + 121, 816 + MCLabel2 + 77, 12 + + + + + + Red + DarkGray + + + False + + + + None + True + True + 切割今年以前的日志数据,防止日志数据库过大 + 12, 792 + MCLabel1 + 251, 12 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAAAAAAAAAAABwMAAAAAAQAAAAAAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAAL + + + + False + + + + None + True + True + False + + + + Red + DarkGray + 日志数据切割 + 12, 807 + LastYearDataMove + 103, 31 + 14 + False