Merge remote-tracking branch 'origin/dep' into dep

master
wangsr 1 year ago
commit 5fae34a7e4

@ -11,8 +11,28 @@ namespace Mesnac.Action.ChemicalWeighing.Entity.Report
/// </summary>
public class Report_DryMixer
{
/// <summary>
/// 构造函数
/// </summary>
/// <param name="id"></param>
public Report_DryMixer(Guid id = default)
{
report_Id = id == default ? Guid.NewGuid() : id;
}
/// <summary>
/// 报表Id
/// </summary>
public Guid report_Id { get; set; }
/// <summary>
/// Dos
/// </summary>
public List<DryMixerDos> dos { get;set; }
/// <summary>
/// Mix
/// </summary>
public List<DryMixerMix> mix { get;set; }
}
@ -33,19 +53,19 @@ namespace Mesnac.Action.ChemicalWeighing.Entity.Report
/// <summary>
/// 设定重量
/// </summary>
public string setValue { get; set; }
public double setValue { get; set; }
/// <summary>
/// 设定公差
/// </summary>
public string setToler { get; set; }
public double setToler { get; set; }
/// <summary>
/// 实际重量
/// </summary>
public string actValue { get; set; }
public double actValue { get; set; }
/// <summary>
/// 实际公差
/// </summary>
public string actToLer { get; set; }
public double actToLer { get; set; }
/// <summary>
/// 步骤编号
/// </summary>
@ -83,11 +103,11 @@ namespace Mesnac.Action.ChemicalWeighing.Entity.Report
/// <summary>
/// 温度
/// </summary>
public string mixTemp { get; set; }
public double mixTemp { get; set; }
/// <summary>
/// 速度
/// </summary>
public string mixSpeed { get; set; }
public double mixSpeed { get; set; }
public int mix { get; set; }

@ -1,9 +1,12 @@
using DevExpress.DataAccess.Native.Json;
using DevExpress.Office.Utils;
using DevExpress.XtraPrinting.Native.WebClientUIControl;
using Mesnac.Action.ChemicalWeighing.Entity.Report;
using Mesnac.Codd.Session;
using Microsoft.Office.Interop.Excel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -127,9 +130,6 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
List<DryMixerMix> dryMixerMixes = new List<DryMixerMix> ();
for (int dos = 0;dos< 4; dos++)
{
// var info = BasePlcHelper.Instance.dryerA_dos1_eqNo.LastValue.ToInt();
var info1 = new Entity.DataKeyValue($"dryer{machineType}_dos{dos}_eqNo").LastValue.ToInt();
var info2 = new Entity.DataKeyValue($"dryer{machineType}_dos{dos}_batch").NowValue.ToInt();
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");
@ -142,20 +142,18 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
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(),
setValue = BasePlcHelper.Instance.dryer_setValue.NowValue.ToDouble(),
setToler = BasePlcHelper.Instance.dryer_setToler.NowValue.ToDouble(),
actValue = BasePlcHelper.Instance.dryer_actValue.NowValue.ToDouble(),
actToLer = BasePlcHelper.Instance.dryer_actToLer.NowValue.ToDouble(),
dos = dos,
recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
};
// _dryMixer.dos = new List<DryMixerDos> { dryMixerDos };
dryMixerDoes.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");
@ -169,8 +167,8 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
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(),
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")
};
@ -196,6 +194,17 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
try
{
string str = serializer.Serialize(_dryMixer);
if(_dryMixer != null)
{
if(_dryMixer.dos != null)
{
InsertReportDryMixer(_dryMixer.report_Id,_dryMixer.dos);
}else if(_dryMixer.mix != null)
{
InsertReportDryMixerDetail(_dryMixer.report_Id, _dryMixer.mix);
}
}
ICSharpCode.Core.LoggingService<GHFinshBatchHelper>.Warn($"报表数据打印:{str}");
}
@ -204,5 +213,221 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
ICSharpCode.Core.LoggingService<GHFinshBatchHelper>.Error(String.Format("保存报表数据至数据库异常:{0}", ex.Message), ex);
}
}
/// <summary>
/// 保存干混机报表数据
/// </summary>
/// <param name="reportId"></param>
/// <param name="_dryMixerDos"></param>
private static void InsertReportDryMixer(Guid reportId,List<DryMixerDos> dryMixers)
{
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_DryMixer
(reportId, eqNo, batch, matCode, setValue, setToler, actValue, actToLer, dos)
values
(@reportId, @eqNo, @batch, @matCode, @setValue, @setToler, @actValue, @actToLer, @dos)";
foreach (DryMixerDos _dryMixerDos in dryMixers)
{
if (_dryMixerDos.actValue == 0) continue;
dbHelper.ClearParameter();
dbHelper.CommandType = CommandType.Text;
dbHelper.CommandText = sqlStr;
dbHelper.AddParameter("@reportId", reportId);
dbHelper.AddParameter("@eqNo", _dryMixerDos.eqNo);
dbHelper.AddParameter("@batch", _dryMixerDos.batch);
dbHelper.AddParameter("@matCode", _dryMixerDos.matCode);
dbHelper.AddParameter("@setValue", _dryMixerDos.setValue);
dbHelper.AddParameter("@setToler", _dryMixerDos.setToler);
dbHelper.AddParameter("@actValue", _dryMixerDos.actValue);
dbHelper.AddParameter("@actToLer", _dryMixerDos.actToLer);
dbHelper.AddParameter("@dos", _dryMixerDos.dos);
dbHelper.ExecuteNonQuery();
}
});
}catch (Exception ex)
{
ICSharpCode.Core.LoggingService<GHFinshBatchHelper>.Error(String.Format("保存干混机报表数据异常:{0}", ex.Message), ex);
}
}
/// <summary>
/// 保存干混机报表明细数据
/// </summary>
/// <param name="reportId"></param>
/// <param name="_dryMixerMix"></param>
private static void InsertReportDryMixerDetail(Guid reportId, List<DryMixerMix> dryMixers)
{
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_DryMixer_Detail
(reportId, eqNo, mixBatch, mixStep, actCode, mixTime, mixTemp, mixSpeed, mix)
values
(@reportId, @eqNo, @mixBatch, @mixStep, @actCode, @mixTime, @mixTemp, @mixSpeed, @mix)";
foreach (DryMixerMix _dryMixerMix in dryMixers)
{
if (_dryMixerMix.actCode == 0) continue;
dbHelper.ClearParameter();
dbHelper.CommandType = CommandType.Text;
dbHelper.CommandText = sqlStr;
dbHelper.AddParameter("@reportId", reportId);
dbHelper.AddParameter("@eqNo", _dryMixerMix.eqNo);
dbHelper.AddParameter("@mixBatch", _dryMixerMix.mixBatch);
dbHelper.AddParameter("@mixStep", _dryMixerMix.mixStep);
dbHelper.AddParameter("@actCode", _dryMixerMix.actCode);
dbHelper.AddParameter("@mixTime", _dryMixerMix.mixTime);
dbHelper.AddParameter("@mixTemp", _dryMixerMix.mixTemp);
dbHelper.AddParameter("@mixSpeed", _dryMixerMix.mixSpeed);
dbHelper.AddParameter("@mix", _dryMixerMix.mix);
dbHelper.ExecuteNonQuery();
}
});
}catch(Exception ex)
{
ICSharpCode.Core.LoggingService<GHFinshBatchHelper>.Error(String.Format("保存干混机报表明细数据异常:{0}", ex.Message), ex);
}
}
/*create table Report_DryMixer
(
objId int identity
primary key,
reportId varchar(36),
eqNo int,
batch int,
matCode int,
setValue decimal(18, 4),
setToler decimal(18, 4),
actValue decimal(18, 4),
actToLer decimal(18, 4),
dos int,
recordTime datetime default getdate()
)
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer', 'COLUMN',
'objId'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer', 'COLUMN',
'reportId'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer', 'COLUMN', 'eqNo'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer', 'COLUMN', 'batch'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer', 'COLUMN',
'matCode'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer', 'COLUMN',
'setValue'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer', 'COLUMN',
'setToler'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer', 'COLUMN',
'actValue'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer', 'COLUMN',
'actToLer'
go
exec sp_addextendedproperty 'MS_Description', N'dos', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer', 'COLUMN', 'dos'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer', 'COLUMN',
'recordTime'
go
create table Report_DryMixer_Detail
(
objId int identity
primary key,
reportId varchar(36),
eqNo int,
mixBatch int,
mixStep int,
actCode int,
mixTime int,
mixTemp decimal(18, 4),
mixSpeed decimal(18, 4),
mix int,
recordTime datetime default getdate()
)
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer_Detail', 'COLUMN',
'objId'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer_Detail', 'COLUMN',
'reportId'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer_Detail', 'COLUMN',
'eqNo'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer_Detail', 'COLUMN',
'mixBatch'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer_Detail', 'COLUMN',
'mixStep'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer_Detail', 'COLUMN',
'actCode'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer_Detail', 'COLUMN',
'mixTime'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer_Detail', 'COLUMN',
'mixTemp'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer_Detail', 'COLUMN',
'mixSpeed'
go
exec sp_addextendedproperty 'MS_Description', N'mix', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer_Detail', 'COLUMN',
'mix'
go
exec sp_addextendedproperty 'MS_Description', N'', 'SCHEMA', 'dbo', 'TABLE', 'Report_DryMixer_Detail', 'COLUMN',
'recordTime'
go*/
}
}

Loading…
Cancel
Save