change - 干混机报表数据读取

master
wenjy 1 year ago
parent 00ebb2f69d
commit fcdf6ce7d6

@ -3121,5 +3121,180 @@ namespace Mesnac.Action.ChemicalWeighing
public DataKeyValue tst1 { get; set; }
public DataKeyValue tst2 { get; set; }
#region 干混机报表参数 Add By wenjy 2023-08-08 15:40:00
#region 注释代码
/*/// <summary>
/// 设备编号 Dos[0]
/// </summary>
public DataKeyValue dryerA_dos0_eqNo { get; set; }
/// <summary>
/// 批次号 Dos[0]
/// </summary>
public DataKeyValue dryerA_dos0_batch { get; set; }
/// <summary>
/// 物料代码 Dos[0]
/// </summary>
public DataKeyValue dryerA_dos0_matCode { get; set; }
/// <summary>
/// 设定重量 Dos[0]
/// </summary>
public DataKeyValue dryerA_dos0_setValue { get; set; }
/// <summary>
/// 设定公差 Dos[0]
/// </summary>
public DataKeyValue dryerA_dos0_setToler { get; set; }
/// <summary>
/// 实际重量 Dos[0]
/// </summary>
public DataKeyValue dryerA_dos0_actValue { get; set; }
/// <summary>
/// 实际公差 Dos[0]
/// </summary>
public DataKeyValue dryerA_dos0_actToLer { get; set; }
/// <summary>
/// 设备编号 Dos[1]
/// </summary>
public DataKeyValue dryerA_dos1_eqNo { get; set; }
/// <summary>
/// 批次号 Dos[1]
/// </summary>
public DataKeyValue dryerA_dos1_batch { get; set; }
/// <summary>
/// 物料代码 Dos[1]
/// </summary>
public DataKeyValue dryerA_dos1_matCode { get; set; }
/// <summary>
/// 设定重量 Dos[1]
/// </summary>
public DataKeyValue dryerA_dos1_setValue { get; set; }
/// <summary>
/// 设定公差 Dos[1]
/// </summary>
public DataKeyValue dryerA_dos1_setToler { get; set; }
/// <summary>
/// 实际重量 Dos[1]
/// </summary>
public DataKeyValue dryerA_dos1_actValue { get; set; }
/// <summary>
/// 实际公差 Dos[1]
/// </summary>
public DataKeyValue dryerA_dos1_actToLer { get; set; }
/// <summary>
/// 设备编号 Dos[2]
/// </summary>
public DataKeyValue dryerA_dos2_eqNo { get; set; }
/// <summary>
/// 批次号 Dos[2]
/// </summary>
public DataKeyValue dryerA_dos2_batch { get; set; }
/// <summary>
/// 物料代码 Dos[2]
/// </summary>
public DataKeyValue dryerA_dos2_matCode { get; set; }
/// <summary>
/// 设定重量 Dos[2]
/// </summary>
public DataKeyValue dryerA_dos2_setValue { get; set; }
/// <summary>
/// 设定公差 Dos[2]
/// </summary>
public DataKeyValue dryerA_dos2_setToler { get; set; }
/// <summary>
/// 实际重量 Dos[2]
/// </summary>
public DataKeyValue dryerA_dos2_actValue { get; set; }
/// <summary>
/// 实际公差 Dos[2]
/// </summary>
public DataKeyValue dryerA_dos2_actToLer { get; set; }
/// <summary>
/// 设备编号 Dos[3]
/// </summary>
public DataKeyValue dryerA_dos3_eqNo { get; set; }
/// <summary>
/// 批次号 Dos[3]
/// </summary>
public DataKeyValue dryerA_dos3_batch { get; set; }
/// <summary>
/// 物料代码 Dos[3]
/// </summary>
public DataKeyValue dryerA_dos3_matCode { get; set; }
/// <summary>
/// 设定重量 Dos[3]
/// </summary>
public DataKeyValue dryerA_dos3_setValue { get; set; }
/// <summary>
/// 设定公差 Dos[3]
/// </summary>
public DataKeyValue dryerA_dos3_setToler { get; set; }
/// <summary>
/// 实际重量 Dos[3]
/// </summary>
public DataKeyValue dryerA_dos3_actValue { get; set; }
/// <summary>
/// 实际公差 Dos[3]
/// </summary>
public DataKeyValue dryerA_dos3_actToLer { get; set; }*/
#endregion
/// <summary>
/// 设备编号
/// </summary>
public DataKeyValue dryer_eqNo { get; set; }
/// <summary>
/// 批次号
/// </summary>
public DataKeyValue dryer_batch { get; set; }
/// <summary>
/// 物料代码
/// </summary>
public DataKeyValue dryer_matCode { get; set; }
/// <summary>
/// 设定重量
/// </summary>
public DataKeyValue dryer_setValue { get; set; }
/// <summary>
/// 设定公差
/// </summary>
public DataKeyValue dryer_setToler { get; set; }
/// <summary>
/// 实际重量
/// </summary>
public DataKeyValue dryer_actValue { get; set; }
/// <summary>
/// 实际公差
/// </summary>
public DataKeyValue dryer_actToLer { get; set; }
/// <summary>
/// 批次
/// </summary>
public DataKeyValue dryer_mixBatch { get; set; }
/// <summary>
/// 步号
/// </summary>
public DataKeyValue dryer_mixStep { get; set; }
/// <summary>
/// 动作
/// </summary>
public DataKeyValue dryer_actCode { get; set; }
/// <summary>
/// 时间
/// </summary>
public DataKeyValue dryer_mixTime { get; set; }
/// <summary>
/// 温度
/// </summary>
public DataKeyValue dryer_mixTemp { get; set; }
/// <summary>
/// 速度
/// </summary>
public DataKeyValue dryer_mixSpeed { get; set; }
#endregion
}
}

@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mesnac.Action.ChemicalWeighing.Entity.Report
{
/// <summary>
/// 干混机报表
/// </summary>
public class Report_DryMixer
{
public List<DryMixerDos> dos { get;set; }
public List<DryMixerMix> mix { get;set; }
}
public class DryMixerDos
{
/// <summary>
/// 设备编号
/// </summary>
public int eqNo { get; set; }
/// <summary>
/// 批次号
/// </summary>
public int batch { get; set; }
/// <summary>
/// 物料代码
/// </summary>
public int matCode { get; set; }
/// <summary>
/// 设定重量
/// </summary>
public string setValue { get; set; }
/// <summary>
/// 设定公差
/// </summary>
public string setToler { get; set; }
/// <summary>
/// 实际重量
/// </summary>
public string actValue { get; set; }
/// <summary>
/// 实际公差
/// </summary>
public string actToLer { get; set; }
/// <summary>
/// 步骤编号
/// </summary>
public int dos { get; set; }
/// <summary>
/// 记录时间
/// </summary>
public string recordTime { get; set; }
}
public class DryMixerMix
{
/// <summary>
/// 设备编号
/// </summary>
public int eqNo { get; set;}
/// <summary>
/// 批次
/// </summary>
public int mixBatch { get; set; }
/// <summary>
/// 步号
/// </summary>
public int mixStep { get; set; }
/// <summary>
/// 动作
/// </summary>
public int actCode { get; set; }
/// <summary>
/// 时间
/// </summary>
public int mixTime { get; set; }
/// <summary>
/// 温度
/// </summary>
public string mixTemp { get; set; }
/// <summary>
/// 速度
/// </summary>
public string mixSpeed { get; set; }
public int mix { get; set; }
/// <summary>
/// 记录时间
/// </summary>
public string recordTime { get; set; }
}
}

@ -1,4 +1,6 @@
using System;
using Mesnac.Action.ChemicalWeighing.Entity.Report;
using Mesnac.Equips;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -510,5 +512,6 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch
}
}
#endregion
}
}

@ -8,6 +8,7 @@ using ICSharpCode.Core;
using Mesnac.Equips;
using Mesnac.Codd.Session;
using Mesnac.Controls.Base;
using Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper;
namespace Mesnac.Action.ChemicalWeighing.FinishBatch
{
@ -158,6 +159,8 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch
FinishBatchHelper.SaveGHData();
//GHFinshBatchHelper.SaveData();
ReportSaveHelper.SaveDryMixerReport();
#endregion
#region 8、更新物料名称

@ -0,0 +1,196 @@
using DevExpress.DataAccess.Native.Json;
using DevExpress.XtraPrinting.Native.WebClientUIControl;
using Mesnac.Action.ChemicalWeighing.Entity.Report;
using Microsoft.Office.Interop.Excel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
{
public class ReportSaveHelper
{
/// <summary>
/// 干混机报表数据保存
/// </summary>
public static void SaveDryMixerReport()
{
try
{
ICSharpCode.Core.LoggingService<GHFinshBatchHelper>.Debug("干混机报表数据保存开始!!!");
//准备信号读取
#region 注释代码 读取复杂
//if (BasePlcHelper.Instance.RdyRpt_D1.NowValue.ToInt() == 1)
//{
// Report_DryMixer _dryMixer = new Report_DryMixer();
// _dryMixer.eqNo = BasePlcHelper.Instance.dryerA_dos0_eqNo.NowValue.ToInt();
// _dryMixer.batch = BasePlcHelper.Instance.dryerA_dos0_batch.NowValue.ToInt();
// _dryMixer.matCode = BasePlcHelper.Instance.dryerA_dos0_matCode.NowValue.ToInt();
// _dryMixer.setValue = BasePlcHelper.Instance.dryerA_dos0_setValue.NowValue.ToString();
// _dryMixer.setToler = BasePlcHelper.Instance.dryerA_dos0_setToler.NowValue.ToString();
// _dryMixer.actValue = BasePlcHelper.Instance.dryerA_dos0_actValue.NowValue.ToString();
// _dryMixer.actToLer = BasePlcHelper.Instance.dryerA_dos0_actToLer.NowValue.ToString();
// _dryMixer.dos = "0";
// _dryMixer.recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//}
//else if (BasePlcHelper.Instance.RdyRpt_D2.NowValue.ToInt() == 1)
//{
// Report_DryMixer _dryMixer = new Report_DryMixer();
// _dryMixer.eqNo = BasePlcHelper.Instance.dryerA_dos1_eqNo.NowValue.ToInt();
// _dryMixer.batch = BasePlcHelper.Instance.dryerA_dos1_batch.NowValue.ToInt();
// _dryMixer.matCode = BasePlcHelper.Instance.dryerA_dos1_matCode.NowValue.ToInt();
// _dryMixer.setValue = BasePlcHelper.Instance.dryerA_dos1_setValue.NowValue.ToString();
// _dryMixer.setToler = BasePlcHelper.Instance.dryerA_dos1_setToler.NowValue.ToString();
// _dryMixer.actValue = BasePlcHelper.Instance.dryerA_dos1_actValue.NowValue.ToString();
// _dryMixer.actToLer = BasePlcHelper.Instance.dryerA_dos1_actToLer.NowValue.ToString();
// _dryMixer.dos = "1";
// _dryMixer.recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//}
//else if (BasePlcHelper.Instance.RdyRpt_D3.NowValue.ToInt() == 1)
//{
// Report_DryMixer _dryMixer = new Report_DryMixer();
// _dryMixer.eqNo = BasePlcHelper.Instance.dryerA_dos2_eqNo.NowValue.ToInt();
// _dryMixer.batch = BasePlcHelper.Instance.dryerA_dos2_batch.NowValue.ToInt();
// _dryMixer.matCode = BasePlcHelper.Instance.dryerA_dos2_matCode.NowValue.ToInt();
// _dryMixer.setValue = BasePlcHelper.Instance.dryerA_dos2_setValue.NowValue.ToString();
// _dryMixer.setToler = BasePlcHelper.Instance.dryerA_dos2_setToler.NowValue.ToString();
// _dryMixer.actValue = BasePlcHelper.Instance.dryerA_dos2_actValue.NowValue.ToString();
// _dryMixer.actToLer = BasePlcHelper.Instance.dryerA_dos2_actToLer.NowValue.ToString();
// _dryMixer.dos = "2";
// _dryMixer.recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//}
//else if (BasePlcHelper.Instance.RdyRpt_D4.NowValue.ToInt() == 1)
//{
// Report_DryMixer _dryMixer = new Report_DryMixer();
// _dryMixer.eqNo = BasePlcHelper.Instance.dryerA_dos3_eqNo.NowValue.ToInt();
// _dryMixer.batch = BasePlcHelper.Instance.dryerA_dos3_batch.NowValue.ToInt();
// _dryMixer.matCode = BasePlcHelper.Instance.dryerA_dos3_matCode.NowValue.ToInt();
// _dryMixer.setValue = BasePlcHelper.Instance.dryerA_dos3_setValue.NowValue.ToString();
// _dryMixer.setToler = BasePlcHelper.Instance.dryerA_dos3_setToler.NowValue.ToString();
// _dryMixer.actValue = BasePlcHelper.Instance.dryerA_dos3_actValue.NowValue.ToString();
// _dryMixer.actToLer = BasePlcHelper.Instance.dryerA_dos3_actToLer.NowValue.ToString();
// _dryMixer.dos = "3";
// _dryMixer.recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//}
#endregion
if (BasePlcHelper.Instance.RdyRpt_D1.NowValue.ToInt() == 1)
{
Report_DryMixer dryMixer_dos0 = readDryMixer("A"); //读取报表数据
SaveReportDb(dryMixer_dos0); //保存报表数据
}
else if (BasePlcHelper.Instance.RdyRpt_D1.NowValue.ToInt() == 2)
{
Report_DryMixer dryMixer_dos0 = readDryMixer("B"); //读取报表数据
SaveReportDb(dryMixer_dos0); //保存报表数据
}
else if (BasePlcHelper.Instance.RdyRpt_D1.NowValue.ToInt() == 3)
{
Report_DryMixer dryMixer_dos0 = readDryMixer("C"); //读取报表数据
SaveReportDb(dryMixer_dos0); //保存报表数据
}
else if (BasePlcHelper.Instance.RdyRpt_D1.NowValue.ToInt() == 4)
{
Report_DryMixer dryMixer_dos0 = readDryMixer("D"); //读取报表数据
SaveReportDb(dryMixer_dos0); //保存报表数据
}
}
catch (Exception ex)
{
ICSharpCode.Core.LoggingService<GHFinshBatchHelper>.Error(String.Format("干混机报表数据保存异常:{0}", ex.Message), ex);
}
}
/// <summary>
/// 通过PLC读取干混机报表数据
/// </summary>
/// <param name="machineType">干混机A、干混机B</param>
/// <param name="dos">操作步骤Dos[0]、Dos[1]、Dos[2]、Dos[3]</param>
/// <returns></returns>
private static Report_DryMixer readDryMixer( string machineType)
{
Report_DryMixer _dryMixer = null;
try
{
_dryMixer = new Report_DryMixer();
for (int dos = 0;dos< 4; dos++)
{
BasePlcHelper.Instance.dryer_eqNo = new Entity.DataKeyValue($"dryer{machineType}_dos{dos}_eqNo");
BasePlcHelper.Instance.dryer_batch = new Entity.DataKeyValue($"dryer{machineType}_dos{dos}_batch");
BasePlcHelper.Instance.dryer_matCode = new Entity.DataKeyValue($"dryer{machineType}_dos{dos}_matCode");
BasePlcHelper.Instance.dryer_setValue = new Entity.DataKeyValue($"dryer{machineType}_dos{dos}_setValue");
BasePlcHelper.Instance.dryer_setToler = new Entity.DataKeyValue($"dryer{machineType}_dos{dos}_setToler");
BasePlcHelper.Instance.dryer_actValue = new Entity.DataKeyValue($"dryer{machineType}_dos{dos}_actValue");
BasePlcHelper.Instance.dryer_actToLer = new Entity.DataKeyValue($"dryer{machineType}_dos{dos}_actToLer");
DryMixerDos dryMixerDos = new DryMixerDos()
{
eqNo = BasePlcHelper.Instance.dryer_eqNo.NowValue.ToInt(),
batch = BasePlcHelper.Instance.dryer_batch.NowValue.ToInt(),
matCode = BasePlcHelper.Instance.dryer_matCode.NowValue.ToInt(),
setValue = BasePlcHelper.Instance.dryer_setValue.NowValue.ToString(),
setToler = BasePlcHelper.Instance.dryer_setToler.NowValue.ToString(),
actValue = BasePlcHelper.Instance.dryer_actValue.NowValue.ToString(),
actToLer = BasePlcHelper.Instance.dryer_actToLer.NowValue.ToString(),
dos = dos,
recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
};
_dryMixer.dos.Add( dryMixerDos );
}
for (int mix = 0; mix < 10; mix++)
{
//BasePlcHelper.Instance.dryer_eqNo = new Entity.DataKeyValue($"dryer{machineType}_mix{mix}_eqNo");
BasePlcHelper.Instance.dryer_mixBatch = new Entity.DataKeyValue($"dryer{machineType}_mix{mix}_mixBatch");
BasePlcHelper.Instance.dryer_mixStep = new Entity.DataKeyValue($"dryer{machineType}_mix{mix}_mixStep");
BasePlcHelper.Instance.dryer_actCode = new Entity.DataKeyValue($"dryer{machineType}_mix{mix}_actCode");
BasePlcHelper.Instance.dryer_mixTime = new Entity.DataKeyValue($"dryer{machineType}_mix{mix}_mixTime");
BasePlcHelper.Instance.dryer_mixTemp = new Entity.DataKeyValue($"dryer{machineType}_mix{mix}_mixTemp");
BasePlcHelper.Instance.dryer_mixSpeed = new Entity.DataKeyValue($"dryer{machineType}_mix{mix}_mixSpeed");
DryMixerMix dryMixerMix = new DryMixerMix()
{
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.ToString(),
mixSpeed = BasePlcHelper.Instance.dryer_mixSpeed.NowValue.ToString(),
mix = mix,
recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
};
_dryMixer.mix.Add(dryMixerMix);
}
}
catch (Exception ex)
{
ICSharpCode.Core.LoggingService<GHFinshBatchHelper>.Error(String.Format("通过PLC读取干混机报表数读取异常{0}", ex.Message), ex);
}
return _dryMixer;
}
/// <summary>
/// 保存报表数据至数据库
/// </summary>
/// <param name="_dryMixer"></param>
private static void SaveReportDb(Report_DryMixer _dryMixer)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
try
{
string str = serializer.Serialize(_dryMixer);
ICSharpCode.Core.LoggingService<GHFinshBatchHelper>.Warn($"报表数据打印:{str}");
}
catch (Exception ex)
{
ICSharpCode.Core.LoggingService<GHFinshBatchHelper>.Error(String.Format("保存报表数据至数据库异常:{0}", ex.Message), ex);
}
}
}
}

@ -158,6 +158,7 @@
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Serialization.Formatters.Soap" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@ -213,9 +214,11 @@
<Compile Include="DeviceParamManage\WriteDeviceParamInfo.cs" />
<Compile Include="Entity\RecordSaveDataInfo.cs" />
<Compile Include="Entity\Report\LR_BarcodeLog.cs" />
<Compile Include="Entity\Report\Report_DryMixer.cs" />
<Compile Include="Entity\SimplePstRole.cs" />
<Compile Include="Entity\SimplePstUser.cs" />
<Compile Include="FinishBatch\GHFinshBatchHelper.cs" />
<Compile Include="FinishBatch\SaveHelper\ReportSaveHelper.cs" />
<Compile Include="FinishBatch\SCADAHelper\AlarmRefreshActionForExtend.cs" />
<Compile Include="LjAction\InitDbAction.cs" />
<Compile Include="LjDevice\DeviceHelp.cs" />

Loading…
Cancel
Save