From fcdf6ce7d62e748e8e9864b825199de02ef53b39 Mon Sep 17 00:00:00 2001 From: wenjy Date: Tue, 8 Aug 2023 16:55:11 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E5=B9=B2=E6=B7=B7=E6=9C=BA?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E6=95=B0=E6=8D=AE=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BasePlcHelper.cs | 175 ++++++++++++++++ .../Entity/Report/Report_DryMixer.cs | 99 +++++++++ .../FinishBatch/FinishBatchHelper.cs | 5 +- .../FinishBatch/FinishBatchService.cs | 3 + .../SaveHelper/ReportSaveHelper.cs | 196 ++++++++++++++++++ .../Mesnac.Action.ChemicalWeighing.csproj | 3 + 6 files changed, 480 insertions(+), 1 deletion(-) create mode 100644 Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Entity/Report/Report_DryMixer.cs create mode 100644 Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/ReportSaveHelper.cs diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BasePlcHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BasePlcHelper.cs index 5eb0437..4f82343 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BasePlcHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BasePlcHelper.cs @@ -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 注释代码 + /*/// + /// 设备编号 Dos[0] + /// + public DataKeyValue dryerA_dos0_eqNo { get; set; } + /// + /// 批次号 Dos[0] + /// + public DataKeyValue dryerA_dos0_batch { get; set; } + /// + /// 物料代码 Dos[0] + /// + public DataKeyValue dryerA_dos0_matCode { get; set; } + /// + /// 设定重量 Dos[0] + /// + public DataKeyValue dryerA_dos0_setValue { get; set; } + /// + /// 设定公差 Dos[0] + /// + public DataKeyValue dryerA_dos0_setToler { get; set; } + /// + /// 实际重量 Dos[0] + /// + public DataKeyValue dryerA_dos0_actValue { get; set; } + /// + /// 实际公差 Dos[0] + /// + public DataKeyValue dryerA_dos0_actToLer { get; set; } + + + /// + /// 设备编号 Dos[1] + /// + public DataKeyValue dryerA_dos1_eqNo { get; set; } + /// + /// 批次号 Dos[1] + /// + public DataKeyValue dryerA_dos1_batch { get; set; } + /// + /// 物料代码 Dos[1] + /// + public DataKeyValue dryerA_dos1_matCode { get; set; } + /// + /// 设定重量 Dos[1] + /// + public DataKeyValue dryerA_dos1_setValue { get; set; } + /// + /// 设定公差 Dos[1] + /// + public DataKeyValue dryerA_dos1_setToler { get; set; } + /// + /// 实际重量 Dos[1] + /// + public DataKeyValue dryerA_dos1_actValue { get; set; } + /// + /// 实际公差 Dos[1] + /// + public DataKeyValue dryerA_dos1_actToLer { get; set; } + + /// + /// 设备编号 Dos[2] + /// + public DataKeyValue dryerA_dos2_eqNo { get; set; } + /// + /// 批次号 Dos[2] + /// + public DataKeyValue dryerA_dos2_batch { get; set; } + /// + /// 物料代码 Dos[2] + /// + public DataKeyValue dryerA_dos2_matCode { get; set; } + /// + /// 设定重量 Dos[2] + /// + public DataKeyValue dryerA_dos2_setValue { get; set; } + /// + /// 设定公差 Dos[2] + /// + public DataKeyValue dryerA_dos2_setToler { get; set; } + /// + /// 实际重量 Dos[2] + /// + public DataKeyValue dryerA_dos2_actValue { get; set; } + /// + /// 实际公差 Dos[2] + /// + public DataKeyValue dryerA_dos2_actToLer { get; set; } + + /// + /// 设备编号 Dos[3] + /// + public DataKeyValue dryerA_dos3_eqNo { get; set; } + /// + /// 批次号 Dos[3] + /// + public DataKeyValue dryerA_dos3_batch { get; set; } + /// + /// 物料代码 Dos[3] + /// + public DataKeyValue dryerA_dos3_matCode { get; set; } + /// + /// 设定重量 Dos[3] + /// + public DataKeyValue dryerA_dos3_setValue { get; set; } + /// + /// 设定公差 Dos[3] + /// + public DataKeyValue dryerA_dos3_setToler { get; set; } + /// + /// 实际重量 Dos[3] + /// + public DataKeyValue dryerA_dos3_actValue { get; set; } + /// + /// 实际公差 Dos[3] + /// + public DataKeyValue dryerA_dos3_actToLer { get; set; }*/ + #endregion + + /// + /// 设备编号 + /// + public DataKeyValue dryer_eqNo { get; set; } + /// + /// 批次号 + /// + public DataKeyValue dryer_batch { get; set; } + /// + /// 物料代码 + /// + public DataKeyValue dryer_matCode { get; set; } + /// + /// 设定重量 + /// + public DataKeyValue dryer_setValue { get; set; } + /// + /// 设定公差 + /// + public DataKeyValue dryer_setToler { get; set; } + /// + /// 实际重量 + /// + public DataKeyValue dryer_actValue { get; set; } + /// + /// 实际公差 + /// + public DataKeyValue dryer_actToLer { get; set; } + + /// + /// 批次 + /// + public DataKeyValue dryer_mixBatch { get; set; } + /// + /// 步号 + /// + public DataKeyValue dryer_mixStep { get; set; } + /// + /// 动作 + /// + public DataKeyValue dryer_actCode { get; set; } + /// + /// 时间 + /// + public DataKeyValue dryer_mixTime { get; set; } + /// + /// 温度 + /// + public DataKeyValue dryer_mixTemp { get; set; } + /// + /// 速度 + /// + public DataKeyValue dryer_mixSpeed { get; set; } + #endregion + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Entity/Report/Report_DryMixer.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Entity/Report/Report_DryMixer.cs new file mode 100644 index 0000000..fb98543 --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Entity/Report/Report_DryMixer.cs @@ -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 +{ + /// + /// 干混机报表 + /// + public class Report_DryMixer + { + public List dos { get;set; } + + public List mix { get;set; } + } + + public class DryMixerDos + { + /// + /// 设备编号 + /// + public int eqNo { get; set; } + /// + /// 批次号 + /// + public int batch { get; set; } + /// + /// 物料代码 + /// + public int matCode { get; set; } + /// + /// 设定重量 + /// + public string setValue { get; set; } + /// + /// 设定公差 + /// + public string setToler { get; set; } + /// + /// 实际重量 + /// + public string actValue { get; set; } + /// + /// 实际公差 + /// + public string actToLer { get; set; } + /// + /// 步骤编号 + /// + public int dos { get; set; } + + /// + /// 记录时间 + /// + public string recordTime { get; set; } + } + + public class DryMixerMix + { + /// + /// 设备编号 + /// + public int eqNo { get; set;} + + /// + /// 批次 + /// + public int mixBatch { get; set; } + /// + /// 步号 + /// + public int mixStep { get; set; } + /// + /// 动作 + /// + public int actCode { get; set; } + /// + /// 时间 + /// + public int mixTime { get; set; } + /// + /// 温度 + /// + public string mixTemp { get; set; } + /// + /// 速度 + /// + public string mixSpeed { get; set; } + + public int mix { get; set; } + + /// + /// 记录时间 + /// + public string recordTime { get; set; } + } +} diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchHelper.cs index 9eda252..f01e98a 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchHelper.cs @@ -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 + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs index 29ff16b..e86c24a 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs @@ -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、更新物料名称 diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/ReportSaveHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/ReportSaveHelper.cs new file mode 100644 index 0000000..90d250e --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/SaveHelper/ReportSaveHelper.cs @@ -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 + { + /// + /// 干混机报表数据保存 + /// + public static void SaveDryMixerReport() + { + try + { + ICSharpCode.Core.LoggingService.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.Error(String.Format("干混机报表数据保存异常:{0}", ex.Message), ex); + } + } + + /// + /// 通过PLC读取干混机报表数据 + /// + /// 干混机A、干混机B + /// 操作步骤:Dos[0]、Dos[1]、Dos[2]、Dos[3] + /// + 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.Error(String.Format("通过PLC读取干混机报表数读取异常:{0}", ex.Message), ex); + } + return _dryMixer; + } + + /// + /// 保存报表数据至数据库 + /// + /// + private static void SaveReportDb(Report_DryMixer _dryMixer) + { + JavaScriptSerializer serializer = new JavaScriptSerializer(); + try + { + string str = serializer.Serialize(_dryMixer); + + ICSharpCode.Core.LoggingService.Warn($"报表数据打印:{str}"); + } + catch (Exception ex) + { + ICSharpCode.Core.LoggingService.Error(String.Format("保存报表数据至数据库异常:{0}", ex.Message), ex); + } + } + } +} diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index 3a8cb83..6a9047d 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -158,6 +158,7 @@ + @@ -213,9 +214,11 @@ + +