diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/AutoControl.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/AutoControl.cs index baba701..8afdfbf 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/AutoControl.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/AutoControl.cs @@ -289,7 +289,7 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl if (b) { int i = ControlsHelper.SingleSelect(RadioE); - LjLogControl.ManualLogControl("手动下黑粉料向" + i, 3, Convert.ToInt32(TextE.ManualWeight.MCValue.ToString()), i, 2); + LjLogControl.ManualLogControl("手动下黑粉料向" + i, Convert.ToInt32(TextE.ManualWeight.MCValue.ToString()), 3, i, 2); MessageBox.Show("数据下传成功!"); } 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/LjReport/WetWaitTime/ExportToPc.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetWaitTime/ExportToPc.cs index ec15a59..0bc0ee5 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetWaitTime/ExportToPc.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetWaitTime/ExportToPc.cs @@ -149,18 +149,27 @@ namespace Mesnac.Action.ChemicalWeighing.LjReport.WetWaitTime dt.Rows.Add(dr); } - var edr = dt.NewRow(); - edr[0] = "湿混等待时间总和"; - edr[1] = TimeConvert(list.Sum(x => x.MixWaitTime)); - dt.Rows.Add(edr); - var edr1 = dt.NewRow(); - edr1[0] = "RGV等待时间总和"; - edr1[1] = TimeConvert(list.Sum(x => x.RgvWaitTime)); - dt.Rows.Add(edr1); - var edr2 = dt.NewRow(); - edr2[0] = "总等待时间总和"; - edr2[1] = TimeConvert(list.Sum(x => x.MixWaitTime + x.RgvWaitTime)); - dt.Rows.Add(edr2); + + try + { + var edr = dt.NewRow(); + edr[0] = "湿混等待时间总和"; + edr[1] = TimeConvert(list.Sum(x => x.MixWaitTime)); + dt.Rows.Add(edr); + var edr1 = dt.NewRow(); + edr1[0] = "RGV等待时间总和"; + edr1[1] = TimeConvert(list.Sum(x => x.RgvWaitTime)); + dt.Rows.Add(edr1); + var edr2 = dt.NewRow(); + edr2[0] = "总等待时间总和"; + edr2[1] = TimeConvert(list.Sum(x => x.MixWaitTime + x.RgvWaitTime)); + dt.Rows.Add(edr2); + } + catch (OverflowException ex) + { + MessageBox.Show("算术值溢出!请检查数据是否有误"); + } + } /// diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetWaitTime/WetTimeCounting.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetWaitTime/WetTimeCounting.cs index cc33ec4..21ac4a0 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetWaitTime/WetTimeCounting.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetWaitTime/WetTimeCounting.cs @@ -10,6 +10,7 @@ using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; namespace Mesnac.Action.ChemicalWeighing.LjReport.WetWaitTime { @@ -225,18 +226,25 @@ namespace Mesnac.Action.ChemicalWeighing.LjReport.WetWaitTime dt.Rows.Add(dr); } - var edr = dt.NewRow(); - edr[0] = "湿混等待时间总和"; - edr[1] = TimeConvert(list.Sum(x => x.MixWaitTime)); - dt.Rows.Add(edr); - var edr1 = dt.NewRow(); - edr1[0] = "RGV等待时间总和"; - edr1[1] = TimeConvert(list.Sum(x => x.RgvWaitTime)); - dt.Rows.Add(edr1); - var edr2 = dt.NewRow(); - edr2[0] = "总等待时间总和"; - edr2[1] = TimeConvert(list.Sum(x => x.MixWaitTime + x.RgvWaitTime)); - dt.Rows.Add(edr2); + try + { + var edr = dt.NewRow(); + edr[0] = "湿混等待时间总和"; + edr[1] = TimeConvert(list.Sum(x => x.MixWaitTime)); + dt.Rows.Add(edr); + var edr1 = dt.NewRow(); + edr1[0] = "RGV等待时间总和"; + edr1[1] = TimeConvert(list.Sum(x => x.RgvWaitTime)); + dt.Rows.Add(edr1); + var edr2 = dt.NewRow(); + edr2[0] = "总等待时间总和"; + edr2[1] = TimeConvert(list.Sum(x => x.MixWaitTime + x.RgvWaitTime)); + dt.Rows.Add(edr2); + } + catch (OverflowException ex) + { + MessageBox.Show("算术值溢出!请检查数据是否有误"); + } } private string TimeConvert(int t) 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 diff --git a/Main/MCEdit/Data/MCProject/nodeForm/WeterTimeCount.xml b/Main/MCEdit/Data/MCProject/nodeForm/WeterTimeCount.xml index 15eb5e6..402bf55 100644 --- a/Main/MCEdit/Data/MCProject/nodeForm/WeterTimeCount.xml +++ b/Main/MCEdit/Data/MCProject/nodeForm/WeterTimeCount.xml @@ -25,12 +25,11 @@ None True True - False False 348, 12 MoreData 530, 622 - 7 + 9 diff --git a/Main/MCRun/Data/SysConfig/MenuConfig.dat b/Main/MCRun/Data/SysConfig/MenuConfig.dat index d5bd986..d06053f 100644 Binary files a/Main/MCRun/Data/SysConfig/MenuConfig.dat and b/Main/MCRun/Data/SysConfig/MenuConfig.dat differ