|
|
|
@ -30,34 +30,34 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<ReportWetMixerSaveHelper>.Debug("湿混机报表数据保存开始!!!");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//准备信号读取
|
|
|
|
|
if (BasePlcHelper.Instance.RdyRpt_D1.NowValue.ToInt() == 1)
|
|
|
|
|
{
|
|
|
|
|
Report_WetMixer wetMixer_dos0 = readWetMixer("A"); //读取报表数据
|
|
|
|
|
SaveReportDb(wetMixer_dos0); //保存报表数据
|
|
|
|
|
BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.RdyRpt_D1, new object[] { 0 });
|
|
|
|
|
}
|
|
|
|
|
else if (BasePlcHelper.Instance.RdyRpt_D2.NowValue.ToInt() == 1)
|
|
|
|
|
{
|
|
|
|
|
Report_WetMixer wetMixer_dos0 = readWetMixer("B"); //读取报表数据
|
|
|
|
|
SaveReportDb(wetMixer_dos0); //保存报表数据
|
|
|
|
|
BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.RdyRpt_D2, new object[] { 0 });
|
|
|
|
|
}
|
|
|
|
|
else if (BasePlcHelper.Instance.RdyRpt_D3.NowValue.ToInt() == 1)
|
|
|
|
|
{
|
|
|
|
|
Report_WetMixer wetMixer_dos0 = readWetMixer("C"); //读取报表数据
|
|
|
|
|
SaveReportDb(wetMixer_dos0); //保存报表数据
|
|
|
|
|
BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.RdyRpt_D3, new object[] { 0 });
|
|
|
|
|
}
|
|
|
|
|
else if (BasePlcHelper.Instance.RdyRpt_D4.NowValue.ToInt() == 1)
|
|
|
|
|
{
|
|
|
|
|
Report_WetMixer wetMixer_dos0 = readWetMixer("D"); //读取报表数据
|
|
|
|
|
SaveReportDb(wetMixer_dos0); //保存报表数据
|
|
|
|
|
BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.RdyRpt_D4, new object[] { 0 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////准备信号读取
|
|
|
|
|
//if (BasePlcHelper.Instance.RdyRpt_D1.NowValue.ToInt() == 1)
|
|
|
|
|
//{
|
|
|
|
|
// Report_WetMixer wetMixer_dos0 = readWetMixer("A"); //读取报表数据
|
|
|
|
|
// SaveReportDb(wetMixer_dos0); //保存报表数据
|
|
|
|
|
// BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.RdyRpt_D1, new object[] { 0 });
|
|
|
|
|
//}
|
|
|
|
|
//else if (BasePlcHelper.Instance.RdyRpt_D2.NowValue.ToInt() == 1)
|
|
|
|
|
//{
|
|
|
|
|
// Report_WetMixer wetMixer_dos0 = readWetMixer("B"); //读取报表数据
|
|
|
|
|
// SaveReportDb(wetMixer_dos0); //保存报表数据
|
|
|
|
|
// BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.RdyRpt_D2, new object[] { 0 });
|
|
|
|
|
//}
|
|
|
|
|
//else if (BasePlcHelper.Instance.RdyRpt_D3.NowValue.ToInt() == 1)
|
|
|
|
|
//{
|
|
|
|
|
// Report_WetMixer wetMixer_dos0 = readWetMixer("C"); //读取报表数据
|
|
|
|
|
// SaveReportDb(wetMixer_dos0); //保存报表数据
|
|
|
|
|
// BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.RdyRpt_D3, new object[] { 0 });
|
|
|
|
|
//}
|
|
|
|
|
//else if (BasePlcHelper.Instance.RdyRpt_D4.NowValue.ToInt() == 1)
|
|
|
|
|
//{
|
|
|
|
|
// Report_WetMixer wetMixer_dos0 = readWetMixer("D"); //读取报表数据
|
|
|
|
|
// SaveReportDb(wetMixer_dos0); //保存报表数据
|
|
|
|
|
// BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.RdyRpt_D4, new object[] { 0 });
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -158,68 +158,35 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
|
|
|
|
|
/// <param name="_wetMixer"></param>
|
|
|
|
|
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<ReportWetMixerSaveHelper>.Warn($"报表数据打印:{str}");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<ReportWetMixerSaveHelper>.Error(String.Format("保存报表数据至数据库异常:{0}", ex.Message), ex);
|
|
|
|
|
}
|
|
|
|
|
//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<ReportWetMixerSaveHelper>.Warn($"报表数据打印:{str}");
|
|
|
|
|
//}
|
|
|
|
|
//catch (Exception ex)
|
|
|
|
|
//{
|
|
|
|
|
// ICSharpCode.Core.LoggingService<ReportWetMixerSaveHelper>.Error(String.Format("保存报表数据至数据库异常:{0}", ex.Message), ex);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存湿混机报表数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="reportId"></param>
|
|
|
|
|
/// <param name="_wetMixerDos"></param>
|
|
|
|
|
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, eqNo) values (@reportId, @eqNo)";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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<ReportWetMixerSaveHelper>.Error(String.Format("保存湿混机报表数据异常:{0}", ex.Message), ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存湿混机报表明细数据
|
|
|
|
|