You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
549 lines
18 KiB
C#
549 lines
18 KiB
C#
using DataBlockHelper;
|
|
using DataBlockHelper.DBHelpers;
|
|
using DataBlockHelper.Entity.DB2106Entity;
|
|
using DataBlockHelper.Entity.DB2107Entity;
|
|
|
|
using DevExpress.Utils.Extensions;
|
|
using DevExpress.XtraPrinting;
|
|
|
|
using HslCommunication.Enthernet;
|
|
|
|
using ICSharpCode.Core;
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Alarm.PmtAlarm;
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
using Mesnac.Action.ChemicalWeighing.FreeDb;
|
|
using Mesnac.Action.ChemicalWeighing.FreeDb.DBEntity;
|
|
using Mesnac.Action.ChemicalWeighing.FreeDb.DBEntity.Report;
|
|
using Mesnac.Action.ChemicalWeighing.ManualControl;
|
|
using Mesnac.Basic;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Report
|
|
{
|
|
public class ReportReadDb
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
/// 干混料插入日志
|
|
/// </summary>
|
|
public static void ReadFeededDry()
|
|
{
|
|
LoggingService<ReportReadDb>.Debug("读取加料信息"+DateTime.Now.ToString());
|
|
DB2105Helper dB2105Helper = new DB2105Helper();
|
|
List<bool> list=dB2105Helper.FeededDryList();
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
if (list[i])
|
|
{
|
|
var feedValue= new DB2107Helper().Weter[i].FeedValue.ToString("0.#");
|
|
LoggingService<ReportReadDb>.Debug($"{i+1}:{feedValue}");
|
|
var deviceno = (i + 3) / 2;
|
|
// 螺旋1启动向湿混机1
|
|
string logName = $"螺旋{deviceno}启动向湿混机{i + 1}";
|
|
|
|
var value = Convert.ToInt32(Convert.ToDouble(feedValue));
|
|
LoggingService<ReportReadDb>.Info(logName+":"+feedValue);
|
|
|
|
ManualLogControl(logName, value, 5, i + 1);
|
|
DB2105WriteHelper.WriteFalseFeededDry(i + 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 日志插入
|
|
/// </summary>
|
|
/// <param name="logName">日志内容</param>
|
|
/// <param name="value">值</param>
|
|
/// <param name="valuekind">值类型 0无 1水称设定值 2水称称量值 3螺旋设定值 4螺旋称量值</param>
|
|
/// <param name="deviceno">设备编号</param>
|
|
/// <param name="devicekind">设备类型 0无 1水称 2螺旋</param>
|
|
private static void ManualLogControl(string logName, int value, int valuekind, int deviceno)
|
|
{
|
|
var Log = new ManualLogEntity()
|
|
{
|
|
logtext = logName,
|
|
logtime = DateTime.Now,
|
|
userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
value = value,
|
|
deviceno = deviceno,
|
|
devicekind = 2,
|
|
valuekind = valuekind,
|
|
createdate = DateTime.Now.ToString("yyyyMMdd")
|
|
};
|
|
|
|
FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity();
|
|
|
|
|
|
}
|
|
|
|
|
|
public static void Read()
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("开始读取报表");
|
|
DB2107Helper dB2107Helper = new DB2107Helper();
|
|
NormalStatusEntity normal = dB2107Helper.NormalStatus;
|
|
if (normal.RdyRpt_D1)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("干混机1读取报表");
|
|
InsertD(1);
|
|
PlcConnect.Instance.Write("DB2107.5.6", false);
|
|
}
|
|
if (normal.RdyRpt_D2)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("干混机2读取报表");
|
|
InsertD(2);
|
|
PlcConnect.Instance.Write("DB2107.5.7", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_D3)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("干混机3读取报表");
|
|
InsertD(3);
|
|
PlcConnect.Instance.Write("DB2107.6.0", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_D4)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("干混机4读取报表");
|
|
InsertD(4);
|
|
PlcConnect.Instance.Write("DB2107.6.1", false);
|
|
}
|
|
|
|
//InsertG
|
|
|
|
if (normal.RdyRpt_G1)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("糊化机1读取报表");
|
|
InsertG(1);
|
|
PlcConnect.Instance.Write("DB2107.6.2", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_G2)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("糊化机2读取报表");
|
|
InsertG(2);
|
|
PlcConnect.Instance.Write("DB2107.6.3", false);
|
|
}
|
|
if (normal.RdyRpt_G3)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("糊化机3读取报表");
|
|
InsertG(3);
|
|
PlcConnect.Instance.Write("DB2107.6.4", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_G4)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("糊化机4读取报表");
|
|
InsertG(4);
|
|
PlcConnect.Instance.Write("DB2107.6.5", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_G5)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("糊化机5读取报表");
|
|
InsertG(5);
|
|
PlcConnect.Instance.Write("DB2107.6.6", false);
|
|
}
|
|
|
|
|
|
if (normal.RdyRpt_G6)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("糊化机6读取报表");
|
|
InsertG(6);
|
|
PlcConnect.Instance.Write("DB2107.6.7", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_G7)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("糊化机7读取报表");
|
|
InsertG(7);
|
|
PlcConnect.Instance.Write("DB2107.7.0", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_G8)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("糊化机8读取报表");
|
|
InsertG(8);
|
|
PlcConnect.Instance.Write("DB2107.7.1", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_M1)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("湿混机1读取报表");
|
|
InsertM(1);
|
|
PlcConnect.Instance.Write("DB2107.7.2", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_M2)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("湿混机2读取报表");
|
|
InsertM(2);
|
|
PlcConnect.Instance.Write("DB2107.7.3", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_M3)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("湿混机3读取报表");
|
|
InsertM(3);
|
|
PlcConnect.Instance.Write("DB2107.7.4", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_M4)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("湿混机4读取报表");
|
|
InsertM(4);
|
|
PlcConnect.Instance.Write("DB2107.7.5", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_M5)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("湿混机5读取报表");
|
|
InsertM(5);
|
|
PlcConnect.Instance.Write("DB2107.7.6", false);
|
|
}
|
|
|
|
|
|
if (normal.RdyRpt_M6)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("湿混机6读取报表");
|
|
InsertM(6);
|
|
PlcConnect.Instance.Write("DB2107.7.7", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_M7)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("湿混机7读取报表");
|
|
InsertM(7);
|
|
PlcConnect.Instance.Write("DB2107.8.0", false);
|
|
}
|
|
|
|
if (normal.RdyRpt_M8)
|
|
{
|
|
LoggingService<ReportReadDb>.InfoFormatted("湿混机8读取报表");
|
|
InsertM(8);
|
|
PlcConnect.Instance.Write("DB2107.8.1", false);
|
|
}
|
|
}
|
|
|
|
|
|
private static void InsertD(int no)
|
|
{
|
|
DB2106Helper dB2106 = new DB2106Helper();
|
|
Dryer_ dryer = null;
|
|
switch (no)
|
|
{
|
|
case 1:
|
|
dryer = dB2106.DryReport.Dryer_A;
|
|
break;
|
|
case 2:
|
|
dryer = dB2106.DryReport.Dryer_B;
|
|
break;
|
|
case 3:
|
|
dryer = dB2106.DryReport.Dryer_C;
|
|
break;
|
|
case 4:
|
|
dryer = dB2106.DryReport.Dryer_D;
|
|
break;
|
|
}
|
|
|
|
Report_Dry dry = new Report_Dry();
|
|
List<Report_DryDos_Detail> lsDos = new List<Report_DryDos_Detail>();
|
|
List<Report_DryMixer_Detail> lsMix = new List<Report_DryMixer_Detail>();
|
|
|
|
dry.reportId = Guid.NewGuid().ToString("N");
|
|
dry.recipeCode = 0;
|
|
dry.recipeName = "";
|
|
|
|
dry.planCode = 0;
|
|
dry.planName = "";
|
|
dry.recordTime = DateTime.Now;
|
|
dry.dryNo = no;
|
|
dry.Batch = 0;
|
|
|
|
foreach (var item in dryer.Dos)
|
|
{
|
|
if (item.EqNo != 0)
|
|
{
|
|
lsDos.Add(new Report_DryDos_Detail()
|
|
{
|
|
reportId = dry.reportId,
|
|
eqNo = item.EqNo,
|
|
batch = item.Batch,
|
|
matCode = item.MatCode,
|
|
setToler = item.SetToler,
|
|
setValue = item.SetValue,
|
|
actToler = item.ActToler,
|
|
actValue = item.ActValue,
|
|
recordTime = DateTime.Now
|
|
|
|
});
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
foreach (var item in dryer.Mix)
|
|
{
|
|
if (item.EqNo != 0)
|
|
{
|
|
lsMix.Add(new Report_DryMixer_Detail()
|
|
{
|
|
reportId = dry.reportId,
|
|
eqNo = item.EqNo,
|
|
mixBatch = item.MixBatch,
|
|
mixStep = item.MixStep,
|
|
mixSpeed = item.MixSpeed,
|
|
mixTemp = item.MixTemp,
|
|
mixTime = item.MixTime,
|
|
recordTime = DateTime.Now
|
|
});
|
|
}
|
|
}
|
|
|
|
FreeSqlUnit.Instance.Insert(dry).ExecuteAffrows();
|
|
FreeSqlUnit.Instance.Insert(lsDos).ExecuteAffrows();
|
|
FreeSqlUnit.Instance.Insert(lsMix).ExecuteAffrows();
|
|
|
|
}
|
|
|
|
private static void InsertG(int no)
|
|
{
|
|
DB2106Helper dB2106 = new DB2106Helper();
|
|
Gel_ gel = null;
|
|
switch (no)
|
|
{
|
|
case 1:
|
|
gel = dB2106.GelReport.Gel_A;
|
|
break;
|
|
case 2:
|
|
gel = dB2106.GelReport.Gel_B;
|
|
break;
|
|
case 3:
|
|
gel = dB2106.GelReport.Gel_C;
|
|
break;
|
|
case 4:
|
|
gel = dB2106.GelReport.Gel_D;
|
|
break;
|
|
|
|
|
|
case 5:
|
|
gel = dB2106.GelReport.Gel_E;
|
|
break;
|
|
case 6:
|
|
gel = dB2106.GelReport.Gel_F;
|
|
break;
|
|
case 7:
|
|
gel = dB2106.GelReport.Gel_G;
|
|
break;
|
|
case 8:
|
|
gel = dB2106.GelReport.Gel_H;
|
|
break;
|
|
}
|
|
Report_Gel gelDb = new Report_Gel();
|
|
|
|
gelDb.reportId = Guid.NewGuid().ToString("N");
|
|
gelDb.recipeCode = 0;
|
|
gelDb.recipeName = "";
|
|
|
|
gelDb.planCode = 0;
|
|
gelDb.planName = "";
|
|
gelDb.recordTime = DateTime.Now;
|
|
gelDb.gelNo = no;
|
|
gelDb.Batch = 0;
|
|
|
|
|
|
List<Report_GelDoser_Detail> lsdetail = new List<Report_GelDoser_Detail>();
|
|
List<Report_GelMixing_Detail> lsMixing = new List<Report_GelMixing_Detail>();
|
|
|
|
var dosList = gel.GelDosing;
|
|
foreach (var dos in dosList)
|
|
{
|
|
if (dos.EqNo != 0)
|
|
{
|
|
lsdetail.Add(new Report_GelDoser_Detail()
|
|
{
|
|
eqNo = dos.EqNo,
|
|
batch = dos.Batch,
|
|
matCode = dos.MatCode,
|
|
setValue = dos.SetValue,
|
|
setToler = dos.SetToler,
|
|
actToLer = dos.ActToler,
|
|
actValue = dos.ActValue,
|
|
reportId = gelDb.reportId,
|
|
recordTime = DateTime.Now,
|
|
|
|
kinds = 1
|
|
});
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
var mixList = gel.GelMixing;
|
|
foreach (var mix in mixList)
|
|
{
|
|
if (mix.EqNo != 0)
|
|
{
|
|
lsMixing.Add(new Report_GelMixing_Detail()
|
|
{
|
|
eqNo = mix.EqNo,
|
|
mixBatch = mix.MixBatch,
|
|
mixStep = mix.MixStep,
|
|
actCode = mix.ActCode,
|
|
mixTime = mix.MixTime,
|
|
|
|
mixSpeed = mix.MixSpeed,
|
|
|
|
mixTemp = mix.MixTemp,
|
|
|
|
reportId = gelDb.reportId,
|
|
recordTime = DateTime.Now,
|
|
|
|
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
var hotWater = gel.HotWater;
|
|
if (hotWater != null)
|
|
{
|
|
lsdetail.Add(new Report_GelDoser_Detail()
|
|
{
|
|
eqNo = hotWater.EqNo,
|
|
batch = hotWater.Batch,
|
|
matCode = hotWater.MatCode,
|
|
setValue = hotWater.SetValue,
|
|
setToler = hotWater.SetToler,
|
|
actToLer = hotWater.ActToler,
|
|
actValue = hotWater.ActValue,
|
|
reportId = gelDb.reportId,
|
|
recordTime = DateTime.Now,
|
|
|
|
kinds = 2
|
|
});
|
|
}
|
|
|
|
var coolWater = gel.CoolWater;
|
|
if (coolWater != null)
|
|
{
|
|
lsdetail.Add(new Report_GelDoser_Detail()
|
|
{
|
|
eqNo = coolWater.EqNo,
|
|
batch = coolWater.Batch,
|
|
matCode = coolWater.MatCode,
|
|
setValue = coolWater.SetValue,
|
|
setToler = coolWater.SetToler,
|
|
actToLer = coolWater.ActToler,
|
|
actValue = coolWater.ActValue,
|
|
reportId = gelDb.reportId,
|
|
recordTime = DateTime.Now,
|
|
|
|
kinds = 3
|
|
});
|
|
}
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(gelDb).ExecuteAffrows();
|
|
FreeSqlUnit.Instance.Insert(lsdetail).ExecuteAffrows();
|
|
FreeSqlUnit.Instance.Insert(lsMixing).ExecuteAffrows();
|
|
}
|
|
|
|
|
|
|
|
private static void InsertM(int no)
|
|
{
|
|
DB2106Helper dB2106 = new DB2106Helper();
|
|
List<Report_WMixE> ls = null;
|
|
switch (no)
|
|
{
|
|
case 1:
|
|
ls = dB2106.WetReport.WetMixing_A;
|
|
break;
|
|
case 2:
|
|
ls = dB2106.WetReport.WetMixing_B;
|
|
break;
|
|
case 3:
|
|
ls = dB2106.WetReport.WetMixing_C;
|
|
break;
|
|
case 4:
|
|
ls = dB2106.WetReport.WetMixing_D;
|
|
break;
|
|
|
|
|
|
case 5:
|
|
ls = dB2106.WetReport.WetMixing_E;
|
|
break;
|
|
case 6:
|
|
ls = dB2106.WetReport.WetMixing_F;
|
|
break;
|
|
case 7:
|
|
ls = dB2106.WetReport.WetMixing_G;
|
|
break;
|
|
case 8:
|
|
ls = dB2106.WetReport.WetMixing_H;
|
|
break;
|
|
}
|
|
|
|
|
|
Report_WetMixer report = new Report_WetMixer();
|
|
|
|
report.reportId = Guid.NewGuid().ToString("N");
|
|
report.recipeCode = 0;
|
|
report.recipeName = "";
|
|
|
|
report.planCode = 0;
|
|
report.planName = "";
|
|
report.recordTime = DateTime.Now;
|
|
report.WetNo = no;
|
|
report.Batch = 0;
|
|
|
|
List<Report_WetMixer_Detail> lde = new List<Report_WetMixer_Detail>();
|
|
foreach (var item in ls)
|
|
{
|
|
if (item.EqNo != 0)
|
|
{
|
|
lde.Add(new Report_WetMixer_Detail()
|
|
{
|
|
recordTime = DateTime.Now,
|
|
reportId = report.reportId,
|
|
eqNo = item.EqNo,
|
|
mixBatch = item.MixBatch,
|
|
mixSpeed = item.MixSpeed,
|
|
actCode = item.ActCode,
|
|
mixTemp = item.MixTemp,
|
|
mixStep = item.MixStep,
|
|
mixTime = item.MixTime,
|
|
actTolerence = item.ActTolerence,
|
|
actWeight = item.ActWeight,
|
|
|
|
});
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(report).ExecuteAffrows();
|
|
FreeSqlUnit.Instance.Insert(lde).ExecuteAffrows();
|
|
}
|
|
}
|
|
}
|