diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Entity/Report/Report_WetMixer.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Entity/Report/Report_WetMixer.cs
index 6302610..03fde63 100644
--- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Entity/Report/Report_WetMixer.cs
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Entity/Report/Report_WetMixer.cs
@@ -28,7 +28,7 @@ namespace Mesnac.Action.ChemicalWeighing.Entity.Report
///
/// Dos
///
- public List wetmixer { get; set; }
+ public WetMixerDevice wetmixer { get; set; }
///
/// Mix
@@ -36,7 +36,7 @@ namespace Mesnac.Action.ChemicalWeighing.Entity.Report
public List mix { get; set; }
}
- public class WetMixer
+ public class WetMixerDevice
{
///
/// 设备编号
diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs
index ae55319..428f58f 100644
--- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs
@@ -160,6 +160,7 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch
//FinishBatchHelper.SaveGHData();
ReportDryMixerSaveHelper.Instance.Save();
+ ReportWetMixerSaveHelper.Instance.SaveWetMixerReport();
#endregion
#region 8、更新物料名称
diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/ReportSaveHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/ReportSaveHelper.cs
index 967be66..e12f99d 100644
--- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/ReportSaveHelper.cs
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/ReportSaveHelper.cs
@@ -63,29 +63,7 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
}
}
- ///
- /// 湿混机报表数据保存
- ///
- public void SaveWetMixerReport()
- {
- try
- {
- ICSharpCode.Core.LoggingService.Debug("湿混机报表数据保存开始!!!");
-
-
- //准备信号读取
-
-
- Report_WetMixer WetMixer_dos0 = readWetMixer("A"); //读取报表数据
- SaveReportDb(WetMixer_dos0); //保存报表数据
-
-
- }
- catch (Exception ex)
- {
- ICSharpCode.Core.LoggingService.Error(String.Format("湿混机报表数据保存异常:{0}", ex.Message), ex);
- }
- }
+
///
/// 通过PLC读取干混机报表数据
@@ -109,27 +87,7 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
return _dryMixer;
}
- ///
- /// 通过PLC读取湿混机报表数据
- ///
- /// 湿混机A、湿混机B
- ///
- private Report_WetMixer readWetMixer(string machineType)
- {
- Report_WetMixer _wetMixer = null;
- try
- {
- _wetMixer = new Report_WetMixer();
- _wetMixer.wetmixer = readWetMixers(machineType, 4);
- _wetMixer.mix = readWetMixerMix(machineType, 10);
- }
- catch (Exception ex)
- {
- ICSharpCode.Core.LoggingService.Error(String.Format("通过PLC读取湿混机报表数读取异常:{0}", ex.Message), ex);
- }
- return _wetMixer;
- }
-
+
///
/// 读取干混机Dos数据
@@ -207,71 +165,7 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
return dryMixerMixes;
}
- ///
- /// 读取湿混机数据
- ///
- ///
- ///
- ///
- private List readWetMixers(string machineType, int amount)
- {
- List wetMixers = new List();
- for (int mixer = 0; mixer < 10; mixer++)
- {
-
- #region 实例化参数
- BasePlcHelper.Instance.dryer_eqNo = new Entity.DataKeyValue($"wetMixing{machineType}_{mixer}_eqNo");
-
- #endregion
-
- WetMixer wetMixer = new WetMixer()
- {
- eqNo = BasePlcHelper.Instance.dryer_eqNo.NowValue.ToInt(),
- recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- };
- wetMixers.Add(wetMixer);
- }
-
- return wetMixers;
- }
-
- ///
- /// 读取湿混机Mix数据
- ///
- ///
- ///
- ///
- private List readWetMixerMix(string machineType, int amount)
- {
- List wetMixerMixes = new List();
- for (int mix = 0; mix < 10; mix++)
- {
- #region 实例化参数
- BasePlcHelper.Instance.dryer_mixBatch = new Entity.DataKeyValue($"wetMixing{machineType}_{mix}_mixBatch");
- BasePlcHelper.Instance.dryer_mixStep = new Entity.DataKeyValue($"wetMixing{machineType}_{mix}_mixStep");
- BasePlcHelper.Instance.dryer_actCode = new Entity.DataKeyValue($"wetMixing{machineType}_{mix}_actCode");
- BasePlcHelper.Instance.dryer_mixTime = new Entity.DataKeyValue($"wetMixing{machineType}_{mix}_mixTime");
- BasePlcHelper.Instance.dryer_mixTemp = new Entity.DataKeyValue($"wetMixing{machineType}_{mix}_mixTemp");
- BasePlcHelper.Instance.dryer_mixSpeed = new Entity.DataKeyValue($"wetMixing{machineType}_{mix}_mixSpeed");
- #endregion
-
- WetMixerMix wetMixerMix = new WetMixerMix()
- {
- eqNo = BasePlcHelper.Instance.dryer_eqNo.NowValue.ToInt(),
- mixBatch = BasePlcHelper.Instance.dryer_mixBatch.NowValue.ToInt(),
- mixStep = BasePlcHelper.Instance.dryer_matCode.NowValue.ToInt(),
- actCode = BasePlcHelper.Instance.dryer_actCode.NowValue.ToInt(),
- mixTime = BasePlcHelper.Instance.dryer_mixTime.NowValue.ToInt(),
- mixTemp = BasePlcHelper.Instance.dryer_mixTemp.NowValue.ToDouble(),
- mixSpeed = BasePlcHelper.Instance.dryer_mixSpeed.NowValue.ToDouble(),
- mix = mix,
- recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- };
- wetMixerMixes.Add(wetMixerMix);
- }
-
- return wetMixerMixes;
- }
+
///
/// 保存干混机报表数据至数据库
@@ -303,36 +197,7 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
}
}
- ///
- /// 保存湿混机报表数据至数据库
- ///
- ///
- private void SaveReportDb(Report_WetMixer _wetMixer)
- {
- JavaScriptSerializer serializer = new JavaScriptSerializer();
- try
- {
- string str = serializer.Serialize(_wetMixer);
- if (_wetMixer != null)
- {
- if (_wetMixer.wetmixer != null)
- {
- InsertReportWetMixer(_wetMixer.report_Id, _wetMixer.wetmixer);
- }
- else if (_wetMixer.mix != null)
- {
- InsertReportWetMixerDetail(_wetMixer.report_Id, _wetMixer.mix);
- }
- }
-
-
- ICSharpCode.Core.LoggingService.Warn($"报表数据打印:{str}");
- }
- catch (Exception ex)
- {
- ICSharpCode.Core.LoggingService.Error(String.Format("保存报表数据至数据库异常:{0}", ex.Message), ex);
- }
- }
+
///
/// 保存干混机报表数据
@@ -427,89 +292,6 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
}
}
- ///
- /// 保存湿混机报表数据
- ///
- ///
- ///
- private void InsertReportWetMixer(Guid reportId, List wetMixers)
- {
- try
- {
-
- Task.Run(() =>
- {
- DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
- if (dbHelper == null)
- {
- throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
- }
- string sqlStr = @"insert into Report_WetMixer
- (reportId, eqNo)
- values
- (@reportId, @eqNo)";
-
- foreach (WetMixer _wetMixer in wetMixers)
- {
- dbHelper.ClearParameter();
- dbHelper.CommandType = CommandType.Text;
- dbHelper.CommandText = sqlStr;
- dbHelper.AddParameter("@eqNo", _wetMixer.eqNo);
- dbHelper.AddParameter("@reportId", reportId);
- dbHelper.ExecuteNonQuery();
- }
- });
- }
- catch (Exception ex)
- {
- ICSharpCode.Core.LoggingService.Error(String.Format("保存湿混机报表数据异常:{0}", ex.Message), ex);
- }
- }
-
- ///
- /// 保存湿混机报表明细数据
- ///
- ///
- ///
- private void InsertReportWetMixerDetail(Guid reportId, List wetMixers)
- {
- try
- {
- Task.Run(() =>
- {
- DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
- if (dbHelper == null)
- {
- throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
- }
- string sqlStr = @"insert into Report_WetMixer_Detail
- (reportId, eqNo, mixBatch, mixStep, actCode, mixTime, mixTemp, mixSpeed, mix)
- values
- (@reportId, @eqNo, @mixBatch, @mixStep, @actCode, @mixTime, @mixTemp, @mixSpeed, @mix)";
- foreach (WetMixerMix _wetMixerMix in wetMixers)
- {
- if (_wetMixerMix.actCode == 0) continue;
-
- dbHelper.ClearParameter();
- dbHelper.CommandType = CommandType.Text;
- dbHelper.CommandText = sqlStr;
- dbHelper.AddParameter("@reportId", reportId);
- dbHelper.AddParameter("@eqNo", _wetMixerMix.eqNo);
- dbHelper.AddParameter("@mixBatch", _wetMixerMix.mixBatch);
- dbHelper.AddParameter("@mixStep", _wetMixerMix.mixStep);
- dbHelper.AddParameter("@actCode", _wetMixerMix.actCode);
- dbHelper.AddParameter("@mixTime", _wetMixerMix.mixTime);
- dbHelper.AddParameter("@mixTemp", _wetMixerMix.mixTemp);
- dbHelper.AddParameter("@mixSpeed", _wetMixerMix.mixSpeed);
- dbHelper.AddParameter("@mix", _wetMixerMix.mix);
- dbHelper.ExecuteNonQuery();
- }
- });
- }
- catch (Exception ex)
- {
- ICSharpCode.Core.LoggingService.Error(String.Format("保存湿混机报表明细数据异常:{0}", ex.Message), ex);
- }
- }
+
}
}
diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/ReportWetMixerSaveHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/ReportWetMixerSaveHelper.cs
new file mode 100644
index 0000000..e7be5e1
--- /dev/null
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/ReportWetMixerSaveHelper.cs
@@ -0,0 +1,253 @@
+using Mesnac.Action.ChemicalWeighing.Entity.Report;
+using Mesnac.Codd.Session;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Threading.Tasks;
+using System.Web.Script.Serialization;
+
+namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
+{
+ public sealed class ReportWetMixerSaveHelper
+ {
+
+ private static readonly Lazy lazy = new Lazy(() => new ReportWetMixerSaveHelper());
+ public static ReportWetMixerSaveHelper Instance
+ {
+ get
+ {
+ return lazy.Value;
+ }
+ }
+
+ private ReportWetMixerSaveHelper() { }
+
+
+ ///
+ /// 湿混机报表数据保存
+ ///
+ public void SaveWetMixerReport()
+ {
+ try
+ {
+ ICSharpCode.Core.LoggingService.Debug("湿混机报表数据保存开始!!!");
+
+
+ //准备信号读取
+
+
+ Report_WetMixer WetMixer_dos0 = readWetMixer("A"); //读取报表数据
+ SaveReportDb(WetMixer_dos0); //保存报表数据
+
+
+ }
+ catch (Exception ex)
+ {
+ ICSharpCode.Core.LoggingService.Error(String.Format("湿混机报表数据保存异常:{0}", ex.Message), ex);
+ }
+ }
+
+
+ ///
+ /// 通过PLC读取湿混机报表数据
+ ///
+ /// 湿混机A、湿混机B
+ ///
+ private Report_WetMixer readWetMixer(string machineType)
+ {
+ Report_WetMixer _wetMixer = null;
+ try
+ {
+ _wetMixer = new Report_WetMixer();
+ _wetMixer.wetmixer = readWetMixers(machineType);
+ _wetMixer.mix = readWetMixerMix(machineType, 10);
+ }
+ catch (Exception ex)
+ {
+ ICSharpCode.Core.LoggingService.Error(String.Format("通过PLC读取湿混机报表数读取异常:{0}", ex.Message), ex);
+ }
+ return _wetMixer;
+ }
+
+
+
+ ///
+ /// 读取湿混机数据
+ ///
+ ///
+ ///
+ ///
+ private WetMixerDevice readWetMixers(string machineType)
+ {
+ var eqNo = new Entity.DataKeyValue($"wetMixing{machineType}_1_eqNo");
+
+ WetMixerDevice wetMixer = new WetMixerDevice()
+ {
+ eqNo = eqNo.NowValue.ToInt(),
+ recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ };
+
+ return wetMixer;
+ }
+
+ ///
+ /// 读取湿混机Mix数据
+ ///
+ ///
+ ///
+ ///
+ private List readWetMixerMix(string machineType, int amount)
+ {
+ List wetMixerMixes = new List();
+ for (int mix = 0; mix < 10; mix++)
+ {
+ #region 实例化参数
+ var eqNo = new Entity.DataKeyValue($"wetMixing{machineType}_{mix}_eqNo");
+ var mixBatch = new Entity.DataKeyValue($"wetMixing{machineType}_{mix}_mixBatch");
+ var mixStep = new Entity.DataKeyValue($"wetMixing{machineType}_{mix}_mixStep");
+ var actCode = new Entity.DataKeyValue($"wetMixing{machineType}_{mix}_actCode");
+ var mixTime = new Entity.DataKeyValue($"wetMixing{machineType}_{mix}_mixTime");
+ var mixTemp = new Entity.DataKeyValue($"wetMixing{machineType}_{mix}_mixTemp");
+ var mixSpeed = new Entity.DataKeyValue($"wetMixing{machineType}_{mix}_mixSpeed");
+ #endregion
+
+ WetMixerMix wetMixerMix = new WetMixerMix()
+ {
+ eqNo = eqNo.NowValue.ToInt(),
+ mixBatch = mixBatch.NowValue.ToInt(),
+ mixStep = mixStep.NowValue.ToInt(),
+ actCode = actCode.NowValue.ToInt(),
+ mixTime = mixTime.NowValue.ToInt(),
+ mixTemp = mixTemp.NowValue.ToDouble(),
+ mixSpeed = mixSpeed.NowValue.ToDouble(),
+ mix = mix,
+ recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ };
+ wetMixerMixes.Add(wetMixerMix);
+ }
+
+ return wetMixerMixes;
+ }
+
+
+
+ ///
+ /// 保存湿混机报表数据至数据库
+ ///
+ ///
+ private void SaveReportDb(Report_WetMixer _wetMixer)
+ {
+ JavaScriptSerializer serializer = new JavaScriptSerializer();
+ try
+ {
+ string str = serializer.Serialize(_wetMixer);
+ if (_wetMixer != null)
+ {
+ if (_wetMixer.wetmixer != null)
+ {
+ InsertReportWetMixer(_wetMixer.report_Id, _wetMixer.wetmixer);
+ }
+ if (_wetMixer.mix != null)
+ {
+ InsertReportWetMixerDetail(_wetMixer.report_Id, _wetMixer.mix);
+ }
+ }
+
+
+ ICSharpCode.Core.LoggingService.Warn($"报表数据打印:{str}");
+ }
+ catch (Exception ex)
+ {
+ ICSharpCode.Core.LoggingService.Error(String.Format("保存报表数据至数据库异常:{0}", ex.Message), ex);
+ }
+ }
+
+
+
+
+ ///
+ /// 保存湿混机报表数据
+ ///
+ ///
+ ///
+ private void InsertReportWetMixer(Guid reportId, WetMixerDevice wetMixer)
+ {
+ try
+ {
+
+ Task.Run(() =>
+ {
+ DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
+ if (dbHelper == null)
+ {
+ throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
+ }
+ string sqlStr = @"insert into Report_WetMixer
+ (reportId, eqName)
+ values
+ (@reportId, @eqName)";
+
+
+ dbHelper.ClearParameter();
+ dbHelper.CommandType = CommandType.Text;
+ dbHelper.CommandText = sqlStr;
+ dbHelper.AddParameter("@eqName", wetMixer.eqNo);
+ dbHelper.AddParameter("@reportId", reportId);
+ dbHelper.ExecuteNonQuery();
+
+ });
+ }
+ catch (Exception ex)
+ {
+ ICSharpCode.Core.LoggingService.Error(String.Format("保存湿混机报表数据异常:{0}", ex.Message), ex);
+ }
+ }
+
+ ///
+ /// 保存湿混机报表明细数据
+ ///
+ ///
+ ///
+ private void InsertReportWetMixerDetail(Guid reportId, List wetMixerMix)
+ {
+ try
+ {
+ Task.Run(() =>
+ {
+ DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
+ if (dbHelper == null)
+ {
+ throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
+ }
+ string sqlStr = @"insert into Report_WetMixer_Detail
+ (reportId, eqNo, mixBatch, mixStep, actCode, mixTime, mixTemp, mixSpeed, mix)
+ values
+ (@reportId, @eqNo, @mixBatch, @mixStep, @actCode, @mixTime, @mixTemp, @mixSpeed, @mix)";
+ foreach (WetMixerMix _wetMixerMix in wetMixerMix)
+ {
+ if (_wetMixerMix.actCode == 0) continue;
+
+ dbHelper.ClearParameter();
+ dbHelper.CommandType = CommandType.Text;
+ dbHelper.CommandText = sqlStr;
+ dbHelper.AddParameter("@reportId", reportId);
+ dbHelper.AddParameter("@eqNo", _wetMixerMix.eqNo);
+ dbHelper.AddParameter("@mixBatch", _wetMixerMix.mixBatch);
+ dbHelper.AddParameter("@mixStep", _wetMixerMix.mixStep);
+ dbHelper.AddParameter("@actCode", _wetMixerMix.actCode);
+ dbHelper.AddParameter("@mixTime", _wetMixerMix.mixTime);
+ dbHelper.AddParameter("@mixTemp", _wetMixerMix.mixTemp);
+ dbHelper.AddParameter("@mixSpeed", _wetMixerMix.mixSpeed);
+ dbHelper.AddParameter("@mix", _wetMixerMix.mix);
+ dbHelper.ExecuteNonQuery();
+ }
+ });
+ }
+ catch (Exception ex)
+ {
+ ICSharpCode.Core.LoggingService.Error(String.Format("保存湿混机报表明细数据异常:{0}", ex.Message), ex);
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj
index 652dc5b..d1d233f 100644
--- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj
@@ -220,6 +220,7 @@
+
@@ -471,6 +472,10 @@
+
+
+
+
Form
diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/ExportAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/ExportAction.cs
new file mode 100644
index 0000000..8edf2c3
--- /dev/null
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/ExportAction.cs
@@ -0,0 +1,158 @@
+using DevExpress.Utils.Drawing.Helpers;
+using ICSharpCode.Core;
+using Mesnac.Action.Base;
+using Mesnac.Action.ChemicalWeighing.Entity.Report;
+using Mesnac.Action.ChemicalWeighing.Report.ProductionReport;
+using Microsoft.Office.Interop.Excel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Mesnac.Action.ChemicalWeighing.Report.WetMixer
+{
+ ///
+ /// 湿混机报表导出事件
+ ///
+ public class ExportAction : ChemicalWeighingAction, Base.IAction
+ {
+ private Control _clientGridControl = null; //报表明细DGV
+ private DbMCControl _dgvWetMixer = null; //报表数据DGV
+
+ public void Run(RuntimeParameter runtime)
+ {
+ base.RunIni(runtime); //必须要调用的
+ ICSharpCode.Core.LoggingService.Debug("湿混机报表-导出...");
+
+ this._dgvWetMixer = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Report_WetMixer").FirstOrDefault();
+ DataGridView _WetMixerGridView = this._dgvWetMixer.BaseControl as DataGridView;
+
+ if (_WetMixerGridView != null)
+ {
+ WetMixerDevice wetMixerDevice = new WetMixerDevice();
+ wetMixerDevice.eqNo = ParseToInt(_WetMixerGridView.SelectedRows[0].Cells["eqNo"].Value.ToString());
+ wetMixerDevice.recordTime = _WetMixerGridView.SelectedRows[0].Cells["recordTime"].Value.ToString();
+
+ SaveFileDialog sfd = new SaveFileDialog();
+ sfd.Filter = "xls files(*.xls)|*.xls";
+ sfd.FileName = String.Format("湿混机报表_{0:yyyyMMdd}", DateTime.Now);
+ sfd.AddExtension = true;
+ DialogResult result = sfd.ShowDialog();
+
+ if (result == DialogResult.OK)
+ {
+ this._clientGridControl = GetAllControls().Where(x => x.Name.Contains("MultiColHeaderDgv")).FirstOrDefault();
+
+ if (_clientGridControl == null)
+ {
+ ICSharpCode.Core.LoggingService.Warn("{生产报表} 缺少缺少称量名细MultiColHeaderDgv控件...");
+ runtime.IsReturn = false;
+ return;
+ }
+
+ Mesnac.Controls.Default.MultiColHeaderDgv clientGrid = (this._clientGridControl as Mesnac.Controls.Default.MultiColHeaderDgv);
+ System.Data.DataTable dt = clientGrid.DataSource as System.Data.DataTable;
+
+ string fileName = sfd.FileName;
+ if (!String.IsNullOrEmpty(fileName))
+ {
+ try
+ {
+ //写入Excle
+ DataTabletoExcel(fileName, dt, wetMixerDevice);
+ string msg1 = "湿混机报表导出成功"; //导出生产报表数据至Excel成功!
+ ICSharpCode.Core.LoggingService.Info(msg1);
+ MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ catch (Exception ex)
+ {
+ string msg1 = $"湿混机报表导出异常:{ex.Message}";
+ ICSharpCode.Core.LoggingService.Error(msg1);
+ MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.WarnCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ }
+ }
+ }
+ }
+
+ }
+
+ ///
+ /// 写入到Excel文件
+ ///
+ ///
+ ///
+ ///
+ public void DataTabletoExcel(string strFileName, System.Data.DataTable tmpDataTable, WetMixerDevice wetMixerDevice)
+ {
+ ///先得到datatable的行数
+ int rowNum = tmpDataTable.Rows.Count;
+ ///列数
+ int columnNum = tmpDataTable.Columns.Count;
+ ///声明一个应用程序类实例
+ Microsoft.Office.Interop.Excel.Application xlApp = new ApplicationClass();
+
+ //创建一个新工作簿
+ Workbook xlBook = xlApp.Workbooks.Add();
+ ///在工作簿中得到sheet。
+ _Worksheet oSheet = (_Worksheet)xlBook.Worksheets[1];
+
+ #region 绘制列
+
+ //绘制配方名和开始时间
+ oSheet.Cells[1, 1] = "设备";
+ oSheet.Cells[1, 2] = "记录时间";
+ oSheet.Cells[2, 1] = wetMixerDevice.eqNo;
+ oSheet.Cells[2, 2] = wetMixerDevice.recordTime;
+
+
+
+ //自定义方法,绘制合并表头
+ oSheet.Cells[3, 1] = "设备";
+ oSheet.Cells[3, 2] = "Mix";
+ oSheet.Cells[3, 3] = "批次";
+ oSheet.Cells[3, 4] = "步号";
+ oSheet.Cells[3, 5] = "动作";
+ oSheet.Cells[3, 6] = "时间";
+ oSheet.Cells[3, 7] = "温度";
+ oSheet.Cells[3, 8] = "速度";
+ oSheet.Cells[3, 9] = "记录时间";
+
+ #endregion
+
+ //将DataTable中的数据导入Excel中
+ for (int i = 0; i < rowNum; i++)
+ {
+ for (int j = 0; j < columnNum; j++)
+ {
+ ///excel中的列是从1开始的
+ xlApp.Cells[i + 4, j + 1] = tmpDataTable.Rows[i][j].ToString();
+ }
+ }
+ oSheet.SaveAs(strFileName);
+ }
+
+ ///
+ /// 字符串转Int
+ ///
+ ///
+ ///
+ private int ParseToInt(string str)
+ {
+ int returnInt = 0;
+ if (str == null || str.Trim().Length < 1)
+ {
+ return returnInt;
+ }
+ if (int.TryParse(str, out returnInt))
+ {
+ return returnInt;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ }
+}
diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/InitFormAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/InitFormAction.cs
new file mode 100644
index 0000000..ee963d3
--- /dev/null
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/InitFormAction.cs
@@ -0,0 +1,38 @@
+using Mesnac.Action.Base;
+using Mesnac.Controls.Base;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Mesnac.Action.ChemicalWeighing.Report.WetMixer
+{
+ ///
+ /// 湿混机报表窗体初始化事件
+ ///
+ public class InitFormAction : ChemicalWeighingAction, IAction
+ {
+ public void Run(RuntimeParameter runtime)
+ {
+ base.RunIni(runtime); //必须要调用的
+ ICSharpCode.Core.LoggingService.Debug("湿混机报表-窗体初始化...");
+
+ #region 获取界面控件
+
+ DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Report_WetMixer").FirstOrDefault(); //获取本机台计划网格控件
+
+ if (clientGridControl == null)
+ {
+ ICSharpCode.Core.LoggingService.Error("{湿混机报表-窗体加载} 缺少日志网格控件...");
+ return;
+ }
+
+ #endregion
+
+ List mcControllist = GetAllDbMCControlsByOption(DbOptionTypes.Query);//获取所有待初始化控件
+ IBaseControl startdate = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "startdate").FirstOrDefault().BaseControl;
+ startdate.MCValue = DateTime.Now.AddDays(-7);
+ }
+ }
+}
diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/SelectAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/SelectAction.cs
new file mode 100644
index 0000000..9ae1519
--- /dev/null
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/SelectAction.cs
@@ -0,0 +1,81 @@
+using Mesnac.Action.Base;
+using Mesnac.Codd.Session;
+using Mesnac.Controls.Base;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Mesnac.Action.ChemicalWeighing.Report.WetMixer
+{
+ ///
+ /// 湿混机报表查询事件
+ ///
+ public class SelectAction : ChemicalWeighingAction, IAction
+ {
+ public void Run(RuntimeParameter runtime)
+ {
+
+ base.RunIni(runtime); //必须要调用的
+
+ ICSharpCode.Core.LoggingService.Debug("湿混机报表-查询...");
+
+ DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
+ if (dbHelper == null)
+ {
+ ICSharpCode.Core.LoggingService.Error("获取本地数据连接失败...");
+ return;
+ }
+ dbHelper.ClearParameter();
+
+ StringBuilder sbSql = new StringBuilder(@"select t1.objId,t1.reportId,t2.Name as eqNo,t1.recordTime
+ from Report_WetMixer t1
+ left join Device t2 on t1.eqNo = t2.Id
+ where 1=1 ");
+ List mcControllist = GetAllDbMCControlsByOption(DbOptionTypes.Query);//获取所有待初始化控件
+
+ IBaseControl startdate = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "startdate").FirstOrDefault().BaseControl;
+ IBaseControl starttime = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "starttime").FirstOrDefault().BaseControl;
+ if (startdate != null && starttime != null)
+ {
+ //Append
+ sbSql.AppendLine(@"AND t1.recordTime>='" + Convert.ToDateTime(startdate.MCValue).ToString("yyyy-MM-dd") + " " + Convert.ToDateTime(starttime.MCValue).ToShortTimeString() + "' ");
+ }
+ else
+ {
+ ICSharpCode.Core.LoggingService.Debug("{湿混机报表-查询} 缺少key值为startdate或者starttime的时间查询条件...");
+ return;
+ }
+
+ IBaseControl enddate = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "enddate").FirstOrDefault().BaseControl;
+ IBaseControl endtime = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "endtime").FirstOrDefault().BaseControl;
+ if (enddate != null && endtime != null)
+ {
+ sbSql.AppendLine(@"AND t1.recordTime<='" + Convert.ToDateTime(enddate.MCValue).ToString("yyyy-MM-dd") + " " + Convert.ToDateTime(endtime.MCValue).ToShortTimeString() + "' ");
+ }
+ else
+ {
+ ICSharpCode.Core.LoggingService.Debug("{湿混机报表-查询} 缺少key值为enddate或者enddate的时间查询条件...");
+ return;
+ }
+ sbSql.Append(" ORDER BY t1.recordTime desc");
+
+ dbHelper.CommandText = sbSql.ToString();
+ dbHelper.CommandType = System.Data.CommandType.Text;
+ DataTable table = dbHelper.ToDataTable();
+
+ //刷新DataGridView数据
+ DbMCControl _dgvWetMixer = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Report_WetMixer").FirstOrDefault();
+ if (_dgvWetMixer == null || !(_dgvWetMixer.BaseControl is DataGridView))
+ {
+ ICSharpCode.Core.LoggingService.Warn("{湿混机报表-查询} 缺少系统日志DataGridView控件...");
+ runtime.IsReturn = false;
+ return;
+ }
+ _dgvWetMixer.BaseControl.BindDataSource = table;
+ }
+ }
+}
diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/SelectRowAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/SelectRowAction.cs
new file mode 100644
index 0000000..64ef2e1
--- /dev/null
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/SelectRowAction.cs
@@ -0,0 +1,94 @@
+using Mesnac.Action.Base;
+using Mesnac.Action.ChemicalWeighing.Report.ProductionReport;
+using Mesnac.Codd.Session;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Mesnac.Action.ChemicalWeighing.Report.WetMixer
+{
+ ///
+ /// 湿混机报表明细查询事件
+ ///
+ public class SelectRowAction : ChemicalWeighingAction, IAction
+ {
+ private Control _clientGridControl = null; //多维表控件
+
+ public void Run(RuntimeParameter runtime)
+ {
+ base.RunIni(runtime); //必须要调用的
+
+ ICSharpCode.Core.LoggingService.Debug("湿混机报表-明细查询...");
+
+ //获取报表数据
+ DbMCControl _dgvWetMixer = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Report_WetMixer").FirstOrDefault();
+ if (_dgvWetMixer == null || !(_dgvWetMixer.BaseControl is DataGridView))
+ {
+ ICSharpCode.Core.LoggingService.Warn("{生产报表} 缺少湿混机报表DataGridView控件...");
+ runtime.IsReturn = false;
+ return;
+ }
+
+ DataGridView _WetMixerGridView = _dgvWetMixer.BaseControl as DataGridView;
+
+ this._clientGridControl = GetAllControls().Where(x => x.Name.Contains("MultiColHeaderDgv")).FirstOrDefault();
+
+ if (_clientGridControl == null)
+ {
+ ICSharpCode.Core.LoggingService.Warn("{生产报表} 缺少缺少称量名细MultiColHeaderDgv控件...");
+ runtime.IsReturn = false;
+ return;
+ }
+
+ Mesnac.Controls.Default.MultiColHeaderDgv clientGrid = (this._clientGridControl as Mesnac.Controls.Default.MultiColHeaderDgv);
+
+ #region 明细控件格式化
+
+ clientGrid.myColHeaderTreeView = null;
+ clientGrid.DataSource = null;
+ clientGrid.iNodeLevels = 0;
+ clientGrid.ColLists.Clear();
+ clientGrid.ColumnHeadersHeight = 23;
+ clientGrid.ScrollBars = ScrollBars.Both;
+ clientGrid.AllowUserToAddRows = false;
+ clientGrid.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
+ clientGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ clientGrid.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("宋体", 12);
+ clientGrid.DefaultCellStyle.Font = new System.Drawing.Font("宋体", 10);
+ clientGrid.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
+ #endregion
+
+ //获取选中行的ReportId,关联获取明细数据并赋值给明细控件
+ if (_WetMixerGridView.SelectedRows.Count == 1)
+ {
+ string lR_planID = _WetMixerGridView.SelectedRows[0].Cells["reportId"].Value as string;
+
+ //获取数据链接
+ DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
+ if (dbHelper == null)
+ {
+ ICSharpCode.Core.LoggingService.Error("获取本地数据连接失败...");
+ return;
+ }
+ dbHelper.ClearParameter();
+
+ //获取明细数据
+ StringBuilder sqlStr = new StringBuilder(@"select t2.Name as 设备编号,t1.mix as Mix,t1. mixBatch as 批次,t1.mixStep as 步号,t1.actCode as 动作,
+ t1.mixTime as 时间,t1.mixTemp as 温度,t1.mixSpeed as 速度,t1.recordTime as 记录时间
+ from Report_WetMixer_Detail t1
+ left join Device t2 on t1.eqNo = t2.Id
+ where t1.reportId = @reportId");
+ dbHelper.CommandText = sqlStr.ToString();
+ dbHelper.CommandType = System.Data.CommandType.Text;
+ dbHelper.AddParameter("@reportId", lR_planID);
+ DataTable table = dbHelper.ToDataTable();
+
+ clientGrid.DataSource = table;
+ }
+ }
+ }
+}
diff --git a/Main/MCEdit/Data/EventConfig/小料称量/业务测试.xml b/Main/MCEdit/Data/EventConfig/小料称量/业务测试.xml
index a84451e..e69de29 100644
--- a/Main/MCEdit/Data/EventConfig/小料称量/业务测试.xml
+++ b/Main/MCEdit/Data/EventConfig/小料称量/业务测试.xml
@@ -1,57 +0,0 @@
-
-
-
-
-
- 业务测试3
- 业务测试3
-
-
- 生产计划测试
- 生产计划测试
-
-
- 小料Action测试
- 小料Action测试
-
-
- 触发保存报警测试
- 触发保存报警测试
-
-
- 写物料名称
- 写物料名称
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Main/MCEdit/Data/EventConfig/小料称量/我叫锄头.xml b/Main/MCEdit/Data/EventConfig/小料称量/我叫锄头.xml
new file mode 100644
index 0000000..d05a28a
--- /dev/null
+++ b/Main/MCEdit/Data/EventConfig/小料称量/我叫锄头.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+ 窗体初始化
+ 窗体初始化
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Main/MCEdit/Data/EventConfig/小料称量/榄菊报表.湿混机报表.xml b/Main/MCEdit/Data/EventConfig/小料称量/榄菊报表.湿混机报表.xml
new file mode 100644
index 0000000..d9fb4fa
--- /dev/null
+++ b/Main/MCEdit/Data/EventConfig/小料称量/榄菊报表.湿混机报表.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+ 窗体初始化
+ 窗体初始化
+
+
+ 查询
+ 查询湿混机报表
+
+
+ 报表明细
+ 报表明细
+
+
+
+ 导出
+ 导出湿混机报表
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Main/MCEdit/Data/MCProject/nodeDevice.xml b/Main/MCEdit/Data/MCProject/nodeDevice.xml
index b558563..f2388e1 100644
--- a/Main/MCEdit/Data/MCProject/nodeDevice.xml
+++ b/Main/MCEdit/Data/MCProject/nodeDevice.xml
@@ -2610,7 +2610,7 @@
-
+
diff --git a/Main/MCEdit/Data/MCProject/nodeForm/湿混机报表.xml b/Main/MCEdit/Data/MCProject/nodeForm/湿混机报表.xml
index 10d2dc5..8a975bf 100644
--- a/Main/MCEdit/Data/MCProject/nodeForm/湿混机报表.xml
+++ b/Main/MCEdit/Data/MCProject/nodeForm/湿混机报表.xml
@@ -1,5 +1,21 @@