diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj
index 6a9047d..4db16b5 100644
--- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj
@@ -455,6 +455,10 @@
+
+
+
+
diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/ExportAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/ExportAction.cs
index 49304c3..73ab58b 100644
--- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/ExportAction.cs
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/ExportAction.cs
@@ -1,12 +1,165 @@
-using System;
+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.DryMixer
{
- internal class ExportAction
+ ///
+ /// 干混机报表导出事件
+ ///
+ public class ExportAction : ChemicalWeighingAction, Base.IAction
{
+ private Control _clientGridControl = null; //报表明细DGV
+ private DbMCControl _dgvDryMixer = null; //报表数据DGV
+
+ public void Run(RuntimeParameter runtime)
+ {
+ base.RunIni(runtime); //必须要调用的
+ ICSharpCode.Core.LoggingService.Debug("干混机报表-导出...");
+
+ this._dgvDryMixer = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Report_DryMixer").FirstOrDefault();
+ DataGridView _DryMixerGridView = this._dgvDryMixer.BaseControl as DataGridView;
+
+ if (_DryMixerGridView != null)
+ {
+ DryMixerDos dryMixerDos = new DryMixerDos();
+ dryMixerDos.eqNo = ParseToInt(_DryMixerGridView.SelectedRows[0].Cells["eqNo"].Value.ToString());
+ dryMixerDos.dos = ParseToInt(_DryMixerGridView.SelectedRows[0].Cells["dos"].Value.ToString());
+ dryMixerDos.batch = ParseToInt(_DryMixerGridView.SelectedRows[0].Cells["batch"].Value.ToString());
+ dryMixerDos.matCode = ParseToInt(_DryMixerGridView.SelectedRows[0].Cells["matCode"].Value.ToString());
+ dryMixerDos.setValue = Convert.ToDouble(_DryMixerGridView.SelectedRows[0].Cells["setValue"].Value);
+ dryMixerDos.setToler = Convert.ToDouble(_DryMixerGridView.SelectedRows[0].Cells["setToler"].Value);
+ dryMixerDos.actValue = Convert.ToDouble(_DryMixerGridView.SelectedRows[0].Cells["actValue"].Value);
+ dryMixerDos.actToLer = Convert.ToDouble(_DryMixerGridView.SelectedRows[0].Cells["actToLer"].Value);
+ dryMixerDos.recordTime = _DryMixerGridView.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))
+ {
+ //写入Excle
+ DataTabletoExcel(fileName, dt, dryMixerDos);
+ }
+ }
+ }
+
+ }
+
+ ///
+ /// 写入到Excel文件
+ ///
+ ///
+ ///
+ ///
+ public void DataTabletoExcel(string strFileName, System.Data.DataTable tmpDataTable, DryMixerDos dryMixerDos)
+ {
+ ///先得到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] = "Dos";
+ oSheet.Cells[1, 3] = "批次号";
+ oSheet.Cells[1, 4] = "物料代码";
+ oSheet.Cells[1, 5] = "设定重量";
+ oSheet.Cells[1, 6] = "设定公差";
+ oSheet.Cells[1, 7] = "实际重量";
+ oSheet.Cells[1, 8] = "实际公差";
+ oSheet.Cells[1, 9] = "记录时间";
+ oSheet.Cells[2, 1] = dryMixerDos.eqNo;
+ oSheet.Cells[2, 2] = dryMixerDos.dos;
+ oSheet.Cells[2, 3] = dryMixerDos.batch;
+ oSheet.Cells[2, 4] = dryMixerDos.matCode;
+ oSheet.Cells[2, 5] = dryMixerDos.setValue;
+ oSheet.Cells[2, 6] = dryMixerDos.setToler;
+ oSheet.Cells[2, 7] = dryMixerDos.actValue;
+ oSheet.Cells[2, 8] = dryMixerDos.setToler;
+ oSheet.Cells[2, 9] = dryMixerDos.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/DryMixer/InitFormAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/InitFormAction.cs
index b74cf47..fdebc72 100644
--- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/InitFormAction.cs
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/InitFormAction.cs
@@ -32,7 +32,7 @@ namespace Mesnac.Action.ChemicalWeighing.Report.DryMixer
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(-1);
+ startdate.MCValue = DateTime.Now.AddDays(-7);
}
}
}
diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/SelectAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/SelectAction.cs
index d085164..ff266df 100644
--- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/SelectAction.cs
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/SelectAction.cs
@@ -1,12 +1,82 @@
-using System;
+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.DryMixer
{
- internal class SelectAction
+ ///
+ /// 干混机报表查询事件
+ ///
+ 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.batch,t1.matCode,
+ t1.setValue,t1.setToler, t1.actValue,t1.actToLer,t1.dos,t1.recordTime
+ from Report_DryMixer 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 _dgvDryMixer = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Report_DryMixer").FirstOrDefault();
+ if (_dgvDryMixer == null || !(_dgvDryMixer.BaseControl is DataGridView))
+ {
+ ICSharpCode.Core.LoggingService.Warn("{干混机报表-查询} 缺少系统日志DataGridView控件...");
+ runtime.IsReturn = false;
+ return;
+ }
+ _dgvDryMixer.BaseControl.BindDataSource = table;
+ }
}
}
diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/SelectRowAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/SelectRowAction.cs
new file mode 100644
index 0000000..e8725b2
--- /dev/null
+++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/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.DryMixer
+{
+ ///
+ /// 干混机报表明细查询事件
+ ///
+ public class SelectRowAction : ChemicalWeighingAction, IAction
+ {
+ private Control _clientGridControl = null; //多维表控件
+
+ public void Run(RuntimeParameter runtime)
+ {
+ base.RunIni(runtime); //必须要调用的
+
+ ICSharpCode.Core.LoggingService.Debug("干混机报表-明细查询...");
+
+ //获取报表数据
+ DbMCControl _dgvDryMixer = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Report_DryMixer").FirstOrDefault();
+ if (_dgvDryMixer == null || !(_dgvDryMixer.BaseControl is DataGridView))
+ {
+ ICSharpCode.Core.LoggingService.Warn("{生产报表} 缺少干混机报表DataGridView控件...");
+ runtime.IsReturn = false;
+ return;
+ }
+
+ DataGridView _DryMixerGridView = _dgvDryMixer.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 (_DryMixerGridView.SelectedRows.Count == 1)
+ {
+ string lR_planID = _DryMixerGridView.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_DryMixer_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 1448b46..77cc748 100644
--- a/Main/MCEdit/Data/EventConfig/小料称量/榄菊报表.干混机报表.xml
+++ b/Main/MCEdit/Data/EventConfig/小料称量/榄菊报表.干混机报表.xml
@@ -1 +1,51 @@
-
\ No newline at end of file
+
+
+
+
+
+ 窗体初始化
+ 窗体初始化
+
+
+ 查询
+ 查询干混机报表
+
+
+ 报表明细
+ 报表明细
+
+
+ 导出
+ 导出干混机报表
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Main/MCEdit/Data/MCProject/SCWSProject2.mprj b/Main/MCEdit/Data/MCProject/SCWSProject2.mprj
index f09434e..87c9678 100644
--- a/Main/MCEdit/Data/MCProject/SCWSProject2.mprj
+++ b/Main/MCEdit/Data/MCProject/SCWSProject2.mprj
@@ -42,6 +42,7 @@
+
diff --git a/Main/MCEdit/Data/MCProject/nodeForm/Report_DryMixer.xml b/Main/MCEdit/Data/MCProject/nodeForm/Report_DryMixer.xml
new file mode 100644
index 0000000..fab956a
--- /dev/null
+++ b/Main/MCEdit/Data/MCProject/nodeForm/Report_DryMixer.xml
@@ -0,0 +1,320 @@
+
+
+
+ [DataSource1].[Report_DryMixer]
+
+
+ [DataSource1].[Report_DryMixer_Detail]
+
diff --git a/Main/MCEdit/MCEdit.csproj b/Main/MCEdit/MCEdit.csproj
index 3ad1e21..f90624e 100644
--- a/Main/MCEdit/MCEdit.csproj
+++ b/Main/MCEdit/MCEdit.csproj
@@ -154,10 +154,6 @@
-
- {90cc2d8a-dec5-4d2a-82c9-f7a033060dc1}
- Mesnac.Action.ChemicalWeighing
-
{18BCAA9F-D601-43B6-B443-E6B126ADF540}
Mesnac.Controls.Base