add - 添加切割日志功能 按年分割

dep
wangsr 11 months ago
parent 5dba184ec8
commit ad2b494b10

@ -13,7 +13,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjMaterial
{
return new Dictionary<string, object>();
}
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<string, object>());
ExecuteNonQuery(sql, new Dictionary<string, object>());
}
public static void ExecuteNonQuery(string sql, IDictionary<string, object> 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();
}
}
}
}

@ -62,6 +62,21 @@ namespace Mesnac.Action.ChemicalWeighing.Report
return DBHelp.GetTable(sql);
}
/// <summary>
/// 去年数据的转移
/// </summary>
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 +

@ -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;
}
/// <summary>
/// 下发送料请求按钮点击
/// 转移去年的数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);
}
/// <summary>
/// 下发接料请求
/// </summary>
/// <param name="deviceNo"></param>
/// <param name="statu"></param>
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);
});
}
/// <summary>
/// 消除报警按钮点击
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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("数据切割成功");
}
/// <summary>

@ -1,5 +1,70 @@
<Object type="Mesnac.Gui.Common.FrmRunTemplate, Mesnac.Gui.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="LjLogForm" children="Controls">
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MCLabel2" children="Controls">
<Property name="Format">
</Property>
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
<Property name="MCKey" />
<Property name="MCDataSourceID" />
<Property name="IsDbControl">False</Property>
<Property name="InitDataSource" />
<Property name="ActionDataSource" />
<Property name="BindDataSource" />
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text">每年年初点击</Property>
<Property name="Location">121, 816</Property>
<Property name="Name">MCLabel2</Property>
<Property name="Size">77, 12</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MCLabel1" children="Controls">
<Property name="Format">
</Property>
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
<Property name="MCKey" />
<Property name="MCDataSourceID" />
<Property name="IsDbControl">False</Property>
<Property name="InitDataSource" />
<Property name="ActionDataSource" />
<Property name="BindDataSource" />
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text">切割今年以前的日志数据,防止日志数据库过大</Property>
<Property name="Location">12, 792</Property>
<Property name="Name">MCLabel1</Property>
<Property name="Size">251, 12</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCButton, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="LastYearDataMove" children="Controls">
<Property name="ClickActionList">
<Binary>AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAAAAAAAAAAABwMAAAAAAQAAAAAAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAAL</Binary>
</Property>
<Property name="MCKey" />
<Property name="MCDataSourceID" />
<Property name="IsDbControl">False</Property>
<Property name="InitDataSource" />
<Property name="ActionDataSource" />
<Property name="BindDataSource" />
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="MCPurview">False</Property>
<Property name="Format">
</Property>
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
<Property name="Text">日志数据切割</Property>
<Property name="Location">12, 807</Property>
<Property name="Name">LastYearDataMove</Property>
<Property name="Size">103, 31</Property>
<Property name="TabIndex">14</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCDataGridView, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="LogForm" children="Controls">
<Property name="DisplayAllColumn">False</Property>
<Property name="DgvColumn">

Loading…
Cancel
Save