杨威 5 months ago
parent eb3d83f9ce
commit 9c89674060

@ -158,7 +158,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipePlcViews.Count(); i++)
{
var view = recipePlcViews[i];
Dowd(begin, view);
Dowd2(begin, view);
begin += 10;
}
@ -166,7 +166,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowSteps(begin, view);
DowSteps2(begin, view);
begin += 12;
}
@ -183,7 +183,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipePlcViews.Count(); i++)
{
var view = recipePlcViews[i];
Dowd(begin, view);
Dowd2(begin, view);
begin += 10;
}
@ -195,7 +195,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowSteps(begin, view);
DowSteps2(begin, view);
begin += 12;
}
@ -210,7 +210,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipePlcViews.Count(); i++)
{
var view = recipePlcViews[i];
Dowd(begin, view);
Dowd2(begin, view);
begin += 10;
}
@ -221,7 +221,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowSteps(begin, view);
DowSteps2(begin, view);
begin += 12;
}
@ -236,7 +236,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipePlcViews.Count(); i++)
{
var view = recipePlcViews[i];
Dowd(begin, view);
Dowd2(begin, view);
begin += 10;
}
@ -245,7 +245,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowSteps(begin, view);
DowSteps2(begin, view);
begin += 12;
}
@ -263,7 +263,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipePlcViews.Count(); i++)
{
var view = recipePlcViews[i];
Dowd(begin, view);
Dowd2(begin, view);
begin += 10;
}
@ -274,7 +274,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowSteps(begin, view);
DowSteps2(begin, view);
begin += 12;
}
@ -289,7 +289,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipePlcViews.Count(); i++)
{
var view = recipePlcViews[i];
Dowd(begin, view);
Dowd2(begin, view);
begin += 10;
}
@ -301,7 +301,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowSteps(begin, view);
DowSteps2(begin, view);
begin += 12;
}
@ -316,7 +316,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipePlcViews.Count(); i++)
{
var view = recipePlcViews[i];
Dowd(begin, view);
Dowd2(begin, view);
begin += 10;
}
@ -327,7 +327,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowSteps(begin, view);
DowSteps2(begin, view);
begin += 12;
}
@ -343,7 +343,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipePlcViews.Count(); i++)
{
var view = recipePlcViews[i];
Dowd(begin, view);
Dowd2(begin, view);
begin += 10;
}
@ -351,7 +351,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowSteps(begin, view);
DowSteps2(begin, view);
begin += 12;
}
@ -639,7 +639,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipePlcViews.Count(); i++)
{
var view = recipePlcViews[i];
Dowd(begin, view);
Dowd2(begin, view);
begin += 10;
}
@ -647,7 +647,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
for (int i = 0; i < recipeSteps.Count(); i++)
{
var view = recipeSteps[i];
DowSteps(begin, view);
DowSteps2(begin, view);
begin += 12;
}
@ -671,6 +671,33 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
}
private static void Dowd2(int start, RecipePlcView view)
{
int bin = start;
PlcConnect.Instance.Write($"DB2104.{bin}.0", view.Bin);
int set = start + 2;
PlcConnect.Instance.Write($"DB2104.{set}.0", view.Set);
int tolerance = start + 6;
PlcConnect.Instance.Write($"DB2104.{tolerance}.0", view.Tolerance);
}
private static void DowSteps2(int start, Step step)
{
int mixCode = start;
var info = PlcConnect.Instance.Write($"DB2104.{mixCode}.0", step.MixCode);
int mixTime = start + 2;
PlcConnect.Instance.Write($"DB2104.{mixTime}.0", step.MixTime);
int mixTemp = start + 4;
PlcConnect.Instance.Write($"DB2104.{mixTemp}.0", step.MixTemp);
int mixSpeed = start + 8;
PlcConnect.Instance.Write($"DB2104.{mixSpeed}.0", step.MixSpeed);
}
private static void Dowd(int start, RecipePlcView view)
{
int bin = start;

@ -635,7 +635,6 @@
<Compile Include="Report\DryMixer\ExportAction.cs" />
<Compile Include="Report\DryMixer\InitFormAction.cs" />
<Compile Include="Report\DryMixer\SelectAction.cs" />
<Compile Include="Report\DryMixer\SelectRowAction.cs" />
<Compile Include="Report\GelDoser\ExportAction.cs" />
<Compile Include="Report\GelDoser\InitFormAction.cs" />
<Compile Include="Report\GelDoser\SelectAction.cs" />
@ -644,6 +643,7 @@
<Compile Include="Report\OpenDoor\OpenDoor.cs" />
<Compile Include="Report\ReportHelper.cs" />
<Compile Include="Report\ReportReadDb.cs" />
<Compile Include="Report\Sb.cs" />
<Compile Include="Report\WetMixer\ExportAction.cs" />
<Compile Include="Report\WetMixer\InitFormAction.cs" />
<Compile Include="Report\WetMixer\SelectAction.cs" />

@ -0,0 +1,240 @@
using Mesnac.Action.Base;
using Mesnac.Controls.Default;
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
{
public class Sb : ChemicalWeighingAction, IAction
{
private Control _clientGridControl = null; //多维表控件
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用的
var MCCombobox1 = GetAllControls().FirstOrDefault(x => x.Name == "MCCombobox1") as MCCombobox;
ICSharpCode.Core.LoggingService<Sb>.Debug("干混机报表-明细查询...");
//获取报表数据
DbMCControl _dgvDryMixer = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Report_DryMixer").FirstOrDefault();
if (_dgvDryMixer == null || !(_dgvDryMixer.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<Sb>.Warn("{生产报表} 缺少干混机报表DataGridView控件...");
runtime.IsReturn = false;
return;
}
DataGridView _DryMixerGridView = _dgvDryMixer.BaseControl as DataGridView;
this._clientGridControl = GetAllControls().Where(x => x.Name.Contains("MultiColHeaderDgv1")).FirstOrDefault();
Mesnac.Controls.Default.MultiColHeaderDgv clientGrid = (this._clientGridControl as Mesnac.Controls.Default.MultiColHeaderDgv);
Mesnac.Controls.Default.MultiColHeaderDgv clientGrid2 = (GetAllControls().Where(x => x.Name.Contains("MultiColHeaderDgv2")).FirstOrDefault() 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;
clientGrid2.myColHeaderTreeView = null;
clientGrid2.DataSource = null;
clientGrid2.iNodeLevels = 0;
clientGrid2.ColLists.Clear();
clientGrid2.ColumnHeadersHeight = 23;
clientGrid2.ScrollBars = ScrollBars.Both;
clientGrid2.AllowUserToAddRows = false;
clientGrid2.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
clientGrid2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
clientGrid2.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("宋体", 12);
clientGrid2.DefaultCellStyle.Font = new System.Drawing.Font("宋体", 10);
clientGrid2.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
#endregion
//获取选中行的ReportId关联获取明细数据并赋值给明细控件
if (_DryMixerGridView.SelectedRows.Count == 1)
{
string lR_planID = _DryMixerGridView.SelectedRows[0].Cells["reportId"].Value as string;
//获取数据链接
var dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
dbHelper.ClearParameter();
//获取明细数据
StringBuilder sqlStr = new StringBuilder(@"select t1.batch as 批次号,t2.MName as 物料,
t1.actValue as ,t1.actToler as
from Report_DryDos_Detail t1
left join lj_stock_material t2 on t1.matCode = t2.Code
where t2.MTypeId=1 and t1.reportId = @reportId");
dbHelper.CommandText = sqlStr.ToString();
dbHelper.CommandType = System.Data.CommandType.Text;
dbHelper.AddParameter("@reportId", lR_planID);
DataTable table = dbHelper.ToDataTable();
string bathNo = "0";
foreach (DataRow row in table.Rows)
{
string a = row["批次号"].ToString().Trim();
if (a != "0")
{
bathNo = a; break;
}
}
float zt = 0;
foreach (DataRow row in table.Rows)
{
string a = row["批次号"].ToString().Trim();
if (a == "0")
{
row["批次号"] = bathNo;
}
var aaa= Convert.ToSingle(row["实际重量"]);
zt+= aaa;
row["实际重量"] = Convert.ToSingle(row["实际重量"]).ToString("#0.00");
row["实际公差"] = Convert.ToSingle(row["实际公差"]).ToString("#0.00");
}
var dts=table.NewRow();
dts[1] = "总计";
dts["实际重量"] = zt.ToString("#0.00");
table.Rows.Add(dts);
clientGrid.DataSource = null;
clientGrid.DataSource = table;
dbHelper.ClearParameter();
string sql = $"select t1.actCode, t1.mixBatch as 批次,t1.mixStep as 步号,t1.actCode as 动作,\r\n " +
$" t1.mixTime as 时间,t1.mixTemp as 温度,t1.mixSpeed as 速度, t1.recordTime as 记录时间 from" +
$" Report_DryMixer_Detail t1\r\n\r\nwhere t1.reportId='{lR_planID}' order by actCode";
dbHelper.CommandText = sql.ToString();
dbHelper.CommandType = System.Data.CommandType.Text;
DataTable tableB = dbHelper.ToDataTable();
DataTable newTable = GetDefault();
var dateNow = DateTime.Now;
Dictionary<int, int> dic = new Dictionary<int, int>();
Dictionary<int, DateTime> Newdic = new Dictionary<int, DateTime>();
foreach (DataRow row in tableB.Rows)
{
var dr = newTable.NewRow();
dr["批次"] = row["批次"];
dr["步号"] = row["步号"];
dr["动作"] = DryStepConvert(Convert.ToInt32(row["actCode"]));
dr["时间"] = ConverToTime(Convert.ToInt32(row["时间"]));
dr["速度"] = row["速度"];
dr["记录时间"] = row["记录时间"];
dr["速度"] = Convert.ToSingle(row["速度"]).ToString("#0.00");
dateNow = Convert.ToDateTime(row["记录时间"].ToString());
dic.Add(Convert.ToInt32(dr["步号"]), Convert.ToInt32(row["时间"]));
newTable.Rows.Add(dr);
}
for (int i = 1; i < 11; i++)
{
var miao = dic.Where(x => x.Key >= i).Select(x => x.Value).Sum();
Newdic.Add(i, dateNow.AddSeconds(-miao));
}
foreach (System.Data.DataRow row in newTable.Rows)
{
var bu = Convert.ToInt32(row["步号"]);
if (Newdic.ContainsKey(bu))
{
var dt = Newdic[bu];
row["记录时间"] = dt.ToString("yyyy-MM-dd HH:mm:ss");
}
}
clientGrid2.DataSource = newTable;
}
}
string ConverToTime(int duration)
{
TimeSpan ts = new TimeSpan(0, 0, Convert.ToInt32(duration));
string str = "";
if (ts.Hours > 0)
{
str = ts.Hours.ToString() + "小时 " + ts.Minutes.ToString() + "分钟 " + ts.Seconds + "秒";
}
if (ts.Hours == 0 && ts.Minutes > 0)
{
str = ts.Minutes.ToString() + "分钟 " + ts.Seconds + "秒";
}
if (ts.Hours == 0 && ts.Minutes == 0)
{
str = ts.Seconds + "秒";
}
return str;
}
private DataTable GetDefault()
{
var tableNewB = new DataTable();
tableNewB.Columns.Add("批次", typeof(string));
tableNewB.Columns.Add("步号", typeof(string));
tableNewB.Columns.Add("动作", typeof(string));
tableNewB.Columns.Add("时间", typeof(string));
//tableNewB.Columns.Add("温度", typeof(string));
tableNewB.Columns.Add("速度", typeof(string));
tableNewB.Columns.Add("记录时间", typeof(string));
return tableNewB;
}
private string DryStepConvert(int code)
{
switch (code)
{
case 1: return "加粉料";
case 4: return "搅拌";
case 6: return "等待排料";
default: return "无";
}
}
}
}

@ -44,7 +44,7 @@
<Import assembly = "Data/Action/ChemicalWeighing/Mesnac.Action.ChemicalWeighing.dll">
<Action action="0402fa6aa1e84dc592c339d4a844325e" class="Mesnac.Action.ChemicalWeighing.Report.DryMixer.InitFormAction"/>
<Action action="7ca1f6c6a347415da9667325aadd7639" class="Mesnac.Action.ChemicalWeighing.Report.DryMixer.SelectAction"/>
<Action action="b0cb9720ab3340eabf0a765adf54fbde" class="Mesnac.Action.ChemicalWeighing.Report.DryMixer.SelectRowAction"/>
<Action action="b0cb9720ab3340eabf0a765adf54fbde" class="Mesnac.Action.ChemicalWeighing.Report.Sb"/>
<Action action="38575e7aef0e4e99a1621db97b9633ce" class="Mesnac.Action.ChemicalWeighing.Report.DryMixer.ExportAction"/>
</Import>
</Runtime>

Loading…
Cancel
Save