change - 代码整理

master
wenjy 2 years ago
parent ae8f502a86
commit 3c9dd0e37f

@ -25,61 +25,6 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
{
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"); //读取报表数据
@ -123,59 +68,9 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
Report_DryMixer _dryMixer = null;
try
{
var s= BasePlcHelper.Instance.dryerA_dos0_eqNo.LastValue.ToInt();
_dryMixer = new Report_DryMixer();
List<DryMixerDos> dryMixerDoes = new List<DryMixerDos> ();
List<DryMixerMix> dryMixerMixes = new List<DryMixerMix> ();
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.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")
};
dryMixerDoes.Add( dryMixerDos );
}
for (int mix = 0; mix < 10; mix++)
{
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.ToDouble(),
mixSpeed = BasePlcHelper.Instance.dryer_mixSpeed.NowValue.ToDouble(),
mix = mix,
recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
};
dryMixerMixes.Add( dryMixerMix );
}
_dryMixer.dos = dryMixerDoes;
_dryMixer.mix = dryMixerMixes;
_dryMixer.dos = readDryMixerDos(machineType, 4);
_dryMixer.mix = readDryMixerMix(machineType, 10);
}
catch (Exception ex)
{
@ -184,6 +79,83 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
return _dryMixer;
}
/// <summary>
/// 读取干混机Dos数据
/// </summary>
/// <param name="machineType"></param>
/// <param name="amount"></param>
/// <returns></returns>
private static List<DryMixerDos> readDryMixerDos(string machineType,int amount)
{
List<DryMixerDos> dryMixerDoes = new List<DryMixerDos>();
for (int dos = 0; dos < amount; dos++)
{
#region 实例化参数
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");
#endregion
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.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")
};
dryMixerDoes.Add(dryMixerDos);
}
return dryMixerDoes;
}
/// <summary>
/// 读取干混机Mix数据
/// </summary>
/// <param name="machineType"></param>
/// <param name="amount"></param>
/// <returns></returns>
private static List<DryMixerMix> readDryMixerMix(string machineType, int amount)
{
List<DryMixerMix> dryMixerMixes = new List<DryMixerMix>();
for (int mix = 0; mix < 10; mix++)
{
#region 实例化参数
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");
#endregion
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.ToDouble(),
mixSpeed = BasePlcHelper.Instance.dryer_mixSpeed.NowValue.ToDouble(),
mix = mix,
recordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
};
dryMixerMixes.Add(dryMixerMix);
}
return dryMixerMixes;
}
/// <summary>
/// 保存报表数据至数据库
/// </summary>
@ -306,128 +278,5 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch.SaveHelper
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