From 6372b3f2ad6adb1c5b207ddddf936d04ad5e20bb Mon Sep 17 00:00:00 2001 From: SoulStar Date: Mon, 19 May 2025 09:07:17 +0800 Subject: [PATCH] =?UTF-8?q?feat=20-=20PLC=E5=8A=A0=E9=94=81=20=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E4=BC=98=E5=8C=96=20=E6=B7=BB=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=20=E6=B7=BB=E5=8A=A0=E6=8A=A5=E8=A1=A8=E5=92=8C?= =?UTF-8?q?=E8=AF=A6=E8=A1=A8=E5=AF=BC=E5=87=BAEXCEL=20=E9=85=8D=E6=96=B9?= =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HighWayIot.Common/StringChange.cs | 41 + HighWayIot.Plc/DataTypeEnum.cs | 5 + HighWayIot.Plc/PlcConnect.cs | 1008 +++++++---------- HighWayIot.Plc/PlcHelper/RecipeParaHelper.cs | 40 +- HighWayIot.Plc/PlcHelper/RecipeSignal.cs | 4 +- HighWayIot.Plc/PlcHelper/TransferSingal.cs | 28 +- HighWayIot.Plc/PlcHelper/WorkStationHelper.cs | 22 +- .../domain/ExportTableEntity.cs | 44 +- .../domain/ZxDailyReportEntity.cs | 7 + .../domain/ZxWeightEntity.cs | 14 + .../service/SysLogService.cs | 1 + .../service/ZxRecipeParaService.cs | 18 + .../service/ZxRecipePositionParaService.cs | 18 + .../service/ZxRecipeService.cs | 19 - .../service/ZxWeightService.cs | 18 + HighWayIot.Rfid/RfidDataAnalyse.cs | 14 +- .../HighWayIot.TouchSocket.csproj | 20 +- HighWayIot.TouchSocket/app.config | 6 +- HighWayIot.TouchSocket/packages.config | 10 +- HighWayIot.Winform/App.config | 12 +- HighWayIot.Winform/Business/GeneralUtils.cs | 5 +- .../Business/RecipeSendBusiness.cs | 105 +- .../Business/TCPClientFactory.cs | 10 +- .../Business/WorkStationBusiness.cs | 1 + HighWayIot.Winform/HighWayIot.Winform.csproj | 111 +- .../MainForm/BaseForm.Designer.cs | 74 +- HighWayIot.Winform/MainForm/BaseForm.cs | 1 + HighWayIot.Winform/Program.cs | 2 +- .../LogPages/DailyReportPage.cs | 13 +- .../LogPages/DailyReportPage.resx | 33 - .../LogPages/ExportPreviewForm.Designer.cs | 346 ++++++ .../LogPages/ExportPreviewForm.cs | 298 ++++- .../LogPages/ExportPreviewForm.resx | 72 ++ .../LogPages/OperateConfigPage.cs | 2 +- .../MaterialConfigPages/MaterialAddForm.cs | 1 + .../MaterialConfigPages/MaterialConfigPage.cs | 1 + .../MaterialTypeConfigPage.cs | 7 + .../MaterialConfigPages/MaterialUpdateForm.cs | 2 +- .../ParamConfigPages/EquipParamSettingPage.cs | 2 + .../ProductionScheduling.Designer.cs | 93 +- .../ParamConfigPages/ProductionScheduling.cs | 47 +- .../ProductionScheduling.resx | 12 +- .../RFIDParamSettingPage.Designer.cs | 58 +- .../ParamConfigPages/RFIDParamSettingPage.cs | 3 + .../RecipeConfigPages/AddRecipeForm.cs | 2 + .../AddWeightForm.Designer.cs | 44 + .../RecipeConfigPages/AddWeightForm.cs | 15 + .../RecipeConfigPage.Designer.cs | 497 +++++--- .../RecipeConfigPages/RecipeConfigPage.cs | 120 +- .../RecipeConfigPages/RecipeConfigPage.resx | 6 + .../UserControlPages/TestPage.cs | 66 +- HighWayIot.Winform/packages.config | 20 + 52 files changed, 2229 insertions(+), 1189 deletions(-) create mode 100644 HighWayIot.Winform/packages.config diff --git a/HighWayIot.Common/StringChange.cs b/HighWayIot.Common/StringChange.cs index 81839d3..483bc09 100644 --- a/HighWayIot.Common/StringChange.cs +++ b/HighWayIot.Common/StringChange.cs @@ -5,6 +5,7 @@ using System.Drawing; using System.IO; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace HighWayIot.Common @@ -212,5 +213,45 @@ namespace HighWayIot.Common } return iNegate; } + + /// + /// 提取字符串中的数字并转换为uint32 + /// + /// + /// + /// + /// + /// + public static uint ExtractUInt32(string input) + { + try + { + if (input == null) + return 0; + // 移除非数字字符(等价于 [^0-9]) + string numberStr = Regex.Replace(input, @"\D", ""); + + if (numberStr.Length == 0) + return 0; + // uint最大值为4294967295(10位) + if (numberStr.Length > 10) + return 0; + + // 处理前导零 + numberStr = numberStr.TrimStart('0'); + + // 全零情况 + if (numberStr.Length == 0) numberStr = "0"; + + if (ulong.Parse(numberStr) > uint.MaxValue) + return 0; + + return uint.Parse(numberStr); + } + catch (Exception ex) + { + return 0; + } + } } } \ No newline at end of file diff --git a/HighWayIot.Plc/DataTypeEnum.cs b/HighWayIot.Plc/DataTypeEnum.cs index 446b458..530539c 100644 --- a/HighWayIot.Plc/DataTypeEnum.cs +++ b/HighWayIot.Plc/DataTypeEnum.cs @@ -67,5 +67,10 @@ namespace HighWayIot.Plc /// [Description("String")] String = 11, + /// + /// Bytes + /// + [Description("Bytes")] + Bytes = 12, } } \ No newline at end of file diff --git a/HighWayIot.Plc/PlcConnect.cs b/HighWayIot.Plc/PlcConnect.cs index 678adad..ff82283 100644 --- a/HighWayIot.Plc/PlcConnect.cs +++ b/HighWayIot.Plc/PlcConnect.cs @@ -1,8 +1,13 @@ using System; +using System.IO; +using System.Runtime.Serialization.Formatters.Binary; +using System.Runtime.Serialization; using System.Threading.Tasks; using HighWayIot.Log4net; using HslCommunication; using HslCommunication.Profinet.Melsec; +using System.Diagnostics; +using System.Linq; namespace HighWayIot.Plc { @@ -21,15 +26,27 @@ namespace HighWayIot.Plc private static LogHelper logHelper = LogHelper.Instance; /// - /// 静态懒加载MelsecMcNet1 开炼机CPU + /// 静态懒加载MelsecMcNet2 读取 CPU /// - //public static readonly MelsecMcNet MelsecInstance1 = new PlcConnect().CreateAb("10.20.48.40"); - //public static readonly MelsecMcNet MelsecInstance1 = new PlcConnect().CreateAb("127.0.0.1"); + public static readonly MelsecMcNet MelsecInstance1 = CreateAb("192.168.0.10", 2001); + /// - /// 静态懒加载MelsecMcNet2 成型机CPU + /// 静态懒加载MelsecMcNet2 写入 CPU /// - public static readonly MelsecMcNet MelsecInstance2 = CreateAb("10.20.48.10"); + public static readonly MelsecMcNet MelsecInstance2 = CreateAb("192.168.0.10", 2002); + + /// + /// 锁对象写 + /// + private static readonly object lockerWrite = new object(); + + /// + /// 锁对象读 + /// + private static readonly object lockerRead = new object(); + + private PlcConnect() { @@ -40,13 +57,13 @@ namespace HighWayIot.Plc /// 初始化三菱的服务器 /// /// - private static MelsecMcNet CreateAb(string ip) + private static MelsecMcNet CreateAb(string ip, int port) { //string Ip = ; MelsecMcNet plc = new MelsecMcNet(); try { - plc.CommunicationPipe = new HslCommunication.Core.Pipe.PipeTcpNet(ip, 2001) + plc.CommunicationPipe = new HslCommunication.Core.Pipe.PipeTcpNet(ip, port) { ConnectTimeOut = 3000, // 连接超时时间,单位毫秒 ReceiveTimeOut = 2000, // 接收超时时间,单位毫秒 @@ -58,7 +75,7 @@ namespace HighWayIot.Plc OperateResult result; result = plc.ConnectServer(); logHelper.Info($"Plc连接 信息:[{result.Message}] 错误代码:[{result.ErrorCode}]"); - + } catch (Exception ex) { @@ -68,638 +85,377 @@ namespace HighWayIot.Plc return plc; } - ///// - ///// plc1 是不是保持链接 - ///// - //public static bool IsConnect1 - //{ - // get - // { - // if (MelsecInstance1 == null) return false; - // var result = MelsecInstance1.ReadBool("B0").IsSuccess; - // logHelper.Info($"PLC[{MelsecInstance1.IpAddress}]连接:[{(result ? "正常" : "异常")}]"); - // return result; - // } - //} + /// + /// PLC2写入数据 + /// + /// 地址 + /// 值 + /// 数据类型 + /// + public static OperateResult PlcWrite2(string address, object value, DataTypeEnum type) + { + var result = new OperateResult() { IsSuccess = false }; + try + { + lock (lockerWrite) + { + //Stopwatch swWrite = new Stopwatch(); + //swWrite.Start(); + switch (type) + { + case DataTypeEnum.Bool: + result = MelsecInstance1.Write(address, Convert.ToBoolean(value)); + break; + case DataTypeEnum.Byte: + result = MelsecInstance1.Write(address, Convert.ToByte(value)); + break; + //case DataTypeEnum.Bytes: + // result = MelsecInstance1.Write(address, ObjectToBytes(value)); + // break; + case DataTypeEnum.Int16: + result = MelsecInstance1.Write(address, Convert.ToInt16(value)); + break; + case DataTypeEnum.UInt16: + result = MelsecInstance1.Write(address, Convert.ToUInt16(value)); + break; + case DataTypeEnum.Int32: + result = MelsecInstance1.Write(address, Convert.ToInt32(value)); + break; + case DataTypeEnum.UInt32: + result = MelsecInstance1.Write(address, Convert.ToUInt32(value)); + break; + case DataTypeEnum.Int64: + result = MelsecInstance1.Write(address, Convert.ToInt64(value)); + break; + case DataTypeEnum.UInt64: + result = MelsecInstance1.Write(address, Convert.ToUInt64(value)); + break; + case DataTypeEnum.Float: + result = MelsecInstance1.Write(address, Convert.ToSingle(value)); + break; + case DataTypeEnum.Double: + result = MelsecInstance1.Write(address, Convert.ToDouble(value)); + break; + case DataTypeEnum.String: + result = MelsecInstance1.Write(address, Convert.ToString(value)); + break; + default: + throw new ArgumentException($"Unsupported data type: {type}"); + } + //swWrite.Stop(); + //logHelper.Info($"Write address:[{address}] value:[{value}] result:[{result.IsSuccess}] time:[{swWrite.ElapsedMilliseconds}]"); + } + } + catch (Exception ex) + { + logHelper.Error("PLC写入数据发生错误!", ex); + } + return result; + } - ///// - ///// plc2 是不是保持链接 - ///// - //public static bool IsConnect2 - //{ - // get - // { - // if (MelsecInstance2 == null) return false; - // var result = MelsecInstance2.ReadBool("D100").IsSuccess; - // logHelper.Info($"PLC[{MelsecInstance2.IpAddress}]连接:[{(result ? "正常" : "异常")}]"); - // return result; - // } - //} + /// + /// 写入byte数组 + /// + /// + /// + /// + public static OperateResult PlcWriteBytes2(string address, byte[] data) + { + OperateResult result = new OperateResult(); + try + { + lock (lockerWrite) + { + result = MelsecInstance2.Write(address, data); + } + } + catch (Exception ex) + { + logHelper.Error($"PLC2写入Bytes发生错误!address:[{address}]", ex); + return default; + } + return result; + } - ///// - ///// PLC1写入数据 - ///// - ///// 地址 - ///// 值 - ///// 数据类型 - ///// - //public static OperateResult PlcWrite1(string address, object value, DataTypeEnum type) - //{ - // var result = new OperateResult() { IsSuccess = false }; - // if (value == null) - // { - // return result; - // } - // try - // { - // switch (type) - // { - // case DataTypeEnum.Bool: - // result = MelsecInstance1.Write(address, Convert.ToBoolean(value)); - // break; - // //case DataTypeEnum.Byte: - // // result = Instance.Write(address, Convert.ToByte(value)); - // // break; - // case DataTypeEnum.Int16: - // result = MelsecInstance1.Write(address, Convert.ToInt16(value)); - // break; - // case DataTypeEnum.UInt16: - // result = MelsecInstance1.Write(address, Convert.ToUInt16(value)); - // break; - // case DataTypeEnum.Int32: - // result = MelsecInstance1.Write(address, Convert.ToInt32(value)); - // break; - // case DataTypeEnum.UInt32: - // result = MelsecInstance1.Write(address, Convert.ToUInt32(value)); - // break; - // case DataTypeEnum.Int64: - // result = MelsecInstance1.Write(address, Convert.ToInt64(value)); - // break; - // case DataTypeEnum.UInt64: - // result = MelsecInstance1.Write(address, Convert.ToUInt64(value)); - // break; - // case DataTypeEnum.Float: - // result = MelsecInstance1.Write(address, Convert.ToSingle(value)); - // break; - // case DataTypeEnum.Double: - // result = MelsecInstance1.Write(address, Convert.ToDouble(value)); - // break; - // case DataTypeEnum.String: - // result = MelsecInstance1.Write(address, Convert.ToString(value)); - // break; - // default: - // throw new ArgumentException($"Unsupported data type: {type}"); - // } - // logHelper.PlcLog($"Read address:[{address}] value:[{value}] type:[{type.ToString()}] result:[{result.IsSuccess}]"); - // } - // catch (Exception ex) - // { - // logHelper.Error("PLC写入数据发生错误!", ex); - // } - // return result; - //} + // 将对象序列化为 byte 数组 + public static byte[] ObjectToBytes(object obj) + { + using (MemoryStream ms = new MemoryStream()) + { + IFormatter formatter = new BinaryFormatter(); + formatter.Serialize(ms, obj); + return ms.ToArray(); + } + } + // 将 byte 数组反序列化为对象 + public static object BytesToObject(byte[] bytes) + { + using (MemoryStream ms = new MemoryStream(bytes)) + { + IFormatter formatter = new BinaryFormatter(); + return formatter.Deserialize(ms); + } + } - ///// - ///// PLC2写入数据 - ///// - ///// 地址 - ///// 值 - ///// 数据类型 - ///// - //public static OperateResult PlcWrite2(string address, object value, DataTypeEnum type) - //{ - // var result = new OperateResult() { IsSuccess = false }; - // try - // { - // switch (type) - // { - // case DataTypeEnum.Bool: - // result = MelsecInstance2.Write(address, Convert.ToBoolean(value)); - // break; - // //case DataTypeEnum.Byte: - // // result = Instance.Write(address, Convert.ToByte(value)); - // // break; - // case DataTypeEnum.Int16: - // result = MelsecInstance2.Write(address, Convert.ToInt16(value)); - // break; - // case DataTypeEnum.UInt16: - // result = MelsecInstance2.Write(address, Convert.ToUInt16(value)); - // break; - // case DataTypeEnum.Int32: - // result = MelsecInstance2.Write(address, Convert.ToInt32(value)); - // break; - // case DataTypeEnum.UInt32: - // result = MelsecInstance2.Write(address, Convert.ToUInt32(value)); - // break; - // case DataTypeEnum.Int64: - // result = MelsecInstance2.Write(address, Convert.ToInt64(value)); - // break; - // case DataTypeEnum.UInt64: - // result = MelsecInstance2.Write(address, Convert.ToUInt64(value)); - // break; - // case DataTypeEnum.Float: - // result = MelsecInstance2.Write(address, Convert.ToSingle(value)); - // break; - // case DataTypeEnum.Double: - // result = MelsecInstance2.Write(address, Convert.ToDouble(value)); - // break; - // case DataTypeEnum.String: - // result = MelsecInstance2.Write(address, Convert.ToString(value)); - // break; - // default: - // throw new ArgumentException($"Unsupported data type: {type}"); - // } - // logHelper.PlcLog($"Read address:[{address}] value:[{value}] type:[{type.ToString()}] result:[{result.IsSuccess}]"); - // } - // catch (Exception ex) - // { - // logHelper.Error("PLC写入数据发生错误!", ex); - // } - // return result; - //} + /// + /// 字符串读取2 + /// + /// + /// + /// + public static OperateResult ReadString2(string address, ushort length) + { + OperateResult result = new OperateResult(); + try + { + lock (lockerRead) + { + result = MelsecInstance2.ReadString(address, length); + } + } + catch (Exception ex) + { + logHelper.Error($"PLC2读取String发生错误!address:[{address}]", ex); + return default; + } + return result; + } - ///// - ///// 字符串读取1 - ///// - ///// - ///// - ///// - //public static string ReadString1(string address, ushort length) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance1.ReadString(address, length); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC1读取String发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} + /// + /// 读取字节数组 + /// + /// + /// + /// + public static OperateResult ReadByte2(string address, ushort length) + { + OperateResult result = new OperateResult(); + try + { + lock (lockerRead) + { + //Stopwatch swRead = new Stopwatch(); + //swRead.Start(); + result = MelsecInstance2.Read(address, length); + //swRead.Stop(); + //logHelper.Info($"Read address:[{address}] length:[{length}] result:[{result.IsSuccess}] time:[{swRead.ElapsedMilliseconds}]"); + } + } + catch (Exception ex) + { + logHelper.Error($"PLC2读取bytes发生错误!address:[{address}]", ex); + return default; + } + return result; + } - ///// - ///// 读取bool - ///// - ///// - ///// - //public static bool ReadBool1(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance1.ReadBool(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Bool发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} + /// + /// 读取bool + /// + /// + /// + public static OperateResult ReadBool2(string address) + { + OperateResult result = new OperateResult(); + try + { + lock (lockerRead) + { + result = MelsecInstance2.ReadBool(address); + } + } + catch (Exception ex) + { + logHelper.Error($"PLC读取Bool发生错误!address:[{address}]", ex); + return default; + } + return result; + } - ///// - ///// 读取Int16 - ///// - ///// - ///// - //public static short ReadInt161(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance1.ReadInt16(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} + /// + /// 读取Int16 + /// + /// + /// + public static OperateResult ReadInt162(string address) + { + OperateResult result = new OperateResult(); + try + { + lock (lockerRead) + { + result = MelsecInstance2.ReadInt16(address); + } + } + catch (Exception ex) + { + logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); + return default; + } + return result; + } - ///// - ///// 读取UInt16 - ///// - ///// - ///// - //public static ushort ReadUInt161(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance1.ReadUInt16(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} + /// + /// 读取UInt16 + /// + /// + /// + public static OperateResult ReadUInt162(string address) + { + OperateResult result = new OperateResult(); + try + { + lock (lockerRead) + { + result = MelsecInstance2.ReadUInt16(address); + } + } + catch (Exception ex) + { + logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); + return default; + } + return result; + } - ///// - ///// 读取Int32 - ///// - ///// - ///// - //public static int ReadInt321(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance1.ReadInt32(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} + /// + /// 读取Int32 + /// + /// + /// + public static OperateResult ReadInt322(string address) + { + OperateResult result = new OperateResult(); + try + { + lock (lockerRead) + { + result = MelsecInstance2.ReadInt32(address); + } + } + catch (Exception ex) + { + logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); + return default; + } + return result; + } - ///// - ///// 读取UInt32 - ///// - ///// - ///// - //public static uint ReadUInt321(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance1.ReadUInt32(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} + /// + /// 读取UInt32 + /// + /// + /// + public static OperateResult ReadUInt322(string address) + { + OperateResult result = new OperateResult(); + try + { + lock (lockerRead) + { + result = MelsecInstance2.ReadUInt32(address); + } + } + catch (Exception ex) + { + logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); + return default; + } + return result; + } - ///// - ///// 读取Int64 - ///// - ///// - ///// - //public static long ReadInt641(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance1.ReadInt64(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} + /// + /// 读取Int64 + /// + /// + /// + public static OperateResult ReadInt642(string address) + { + OperateResult result = new OperateResult(); + try + { + lock(lockerRead) + { + result = MelsecInstance2.ReadInt64(address); + } + } + catch (Exception ex) + { + logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); + return default; + } + return result; + } - ///// - ///// 读取UInt64 - ///// - ///// - ///// - //public static ulong ReadUInt641(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance1.ReadUInt64(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} + /// + /// 读取UInt64 + /// + /// + /// + public static OperateResult ReadUInt642(string address) + { + OperateResult result = new OperateResult(); + try + { + lock (lockerRead) + { + result = MelsecInstance2.ReadUInt64(address); + } + } + catch (Exception ex) + { + logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); + return default; + } + return result; + } - ///// - ///// 读取Float - ///// - ///// - ///// - //public static float ReadFloat1(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance1.ReadFloat(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Float发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} + /// + /// 读取Float + /// + /// + /// + public static OperateResult ReadFloat2(string address) + { + OperateResult result = new OperateResult(); + try + { + lock (lockerRead) + { + result = MelsecInstance2.ReadFloat(address); + } + } + catch (Exception ex) + { + logHelper.Error($"PLC读取Float发生错误!address:[{address}]", ex); + return default; + } + return result; + } - ///// - ///// 读取Double - ///// - ///// - ///// - //public static double ReadDouble1(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance1.ReadDouble(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Double发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} + /// + /// 读取Double + /// + /// + /// + public static OperateResult ReadDouble2(string address) + { + OperateResult result = new OperateResult(); - ///// - ///// 字符串读取2 - ///// - ///// - ///// - ///// - //public static string ReadString2(string address, ushort length) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance2.ReadString(address, length); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC2读取String发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} - - ///// - ///// 读取bool - ///// - ///// - ///// - //public static bool ReadBool2(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance2.ReadBool(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Bool发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} - - ///// - ///// 读取Int16 - ///// - ///// - ///// - //public static short ReadInt162(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance2.ReadInt16(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} - - ///// - ///// 读取UInt16 - ///// - ///// - ///// - //public static ushort ReadUInt162(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance2.ReadUInt16(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} - - ///// - ///// 读取Int32 - ///// - ///// - ///// - //public static int ReadInt322(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance2.ReadInt32(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} - - ///// - ///// 读取UInt32 - ///// - ///// - ///// - //public static uint ReadUInt322(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance2.ReadUInt32(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} - - ///// - ///// 读取Int64 - ///// - ///// - ///// - //public static long ReadInt642(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance2.ReadInt64(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} - - ///// - ///// 读取UInt64 - ///// - ///// - ///// - //public static ulong ReadUInt642(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance2.ReadUInt64(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Int16发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} - - ///// - ///// 读取Float - ///// - ///// - ///// - //public static float ReadFloat2(string address) - //{ - // OperateResult result = new OperateResult(); - // try - // { - // result = MelsecInstance2.ReadFloat(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Float发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} - - ///// - ///// 读取Double - ///// - ///// - ///// - //public static double ReadDouble2(string address) - //{ - // OperateResult result = new OperateResult(); - - // try - // { - // result = MelsecInstance2.ReadDouble(address); - // } - // catch (Exception ex) - // { - // logHelper.Error($"PLC读取Double发生错误!address:[{address}]", ex); - // return default; - // } - // if (!result.IsSuccess) - // { - // return default; - // } - // return result.Content; - //} + try + { + lock (lockerRead) + { + result = MelsecInstance2.ReadDouble(address); + } + } + catch (Exception ex) + { + logHelper.Error($"PLC读取Double发生错误!address:[{address}]", ex); + return default; + } + return result; + } } } \ No newline at end of file diff --git a/HighWayIot.Plc/PlcHelper/RecipeParaHelper.cs b/HighWayIot.Plc/PlcHelper/RecipeParaHelper.cs index d00c09f..a8dcc83 100644 --- a/HighWayIot.Plc/PlcHelper/RecipeParaHelper.cs +++ b/HighWayIot.Plc/PlcHelper/RecipeParaHelper.cs @@ -1,4 +1,5 @@ -using HighWayIot.Repository.domain; +using HighWayIot.Common; +using HighWayIot.Repository.domain; using HslCommunication; using Models; using System; @@ -12,6 +13,8 @@ namespace HighWayIot.Plc.PlcHelper { public class RecipeParaHelper { + #region 写入 + /// /// 数据下传到PLC /// @@ -24,17 +27,17 @@ namespace HighWayIot.Plc.PlcHelper //SPEC编号写入 try { - if (!PlcConnect.MelsecInstance2.Write("D206", uint.Parse(paraEntity.SpecCode)).IsSuccess) + if (!PlcConnect.PlcWrite2("D206", StringChange.ExtractUInt32(paraEntity.SpecCode), DataTypeEnum.UInt32).IsSuccess) return false; } catch { - return false; + return false; } //SPEC名称写入 var specNameBytes = Encoding.ASCII.GetBytes(paraEntity.SpecName); - Array.Copy(specNameBytes, 0, bytes, 0, specNameBytes.Length); + Array.Copy(specNameBytes, 0, bytes, 0, specNameBytes.Length > 20 ? 20 : specNameBytes.Length); //if (!PlcConnect.PlcWrite2("D290", paraEntity.SpecName, DataTypeEnum.String).IsSuccess) // return false; @@ -76,14 +79,13 @@ namespace HighWayIot.Plc.PlcHelper var bytes5 = BitConverter.GetBytes((ushort?)paraEntity.StopDistance ?? 0); var bytes6 = BitConverter.GetBytes(paraEntity.TireWeight ?? 0); Array.Copy(bytes1, 0, bytes, (390 - 290) * 2, bytes1.Length); - Array.Copy(bytes2, 0, bytes, (391 - 290) * 2, bytes1.Length); - Array.Copy(bytes3, 0, bytes, (392 - 290) * 2, bytes1.Length); - Array.Copy(bytes4, 0, bytes, (393 - 290) * 2, bytes1.Length); - Array.Copy(bytes5, 0, bytes, (394 - 290) * 2, bytes1.Length); - Array.Copy(bytes6, 0, bytes, (398 - 290) * 2, bytes1.Length); + Array.Copy(bytes2, 0, bytes, (391 - 290) * 2, bytes2.Length); + Array.Copy(bytes3, 0, bytes, (392 - 290) * 2, bytes3.Length); + Array.Copy(bytes4, 0, bytes, (393 - 290) * 2, bytes4.Length); + Array.Copy(bytes5, 0, bytes, (394 - 290) * 2, bytes5.Length); + Array.Copy(bytes6, 0, bytes, (398 - 290) * 2, bytes6.Length); - - return PlcConnect.MelsecInstance2.Write("D290", bytes).IsSuccess; + return PlcConnect.PlcWriteBytes2("D290", bytes).IsSuccess; } /// @@ -141,6 +143,8 @@ namespace HighWayIot.Plc.PlcHelper if (value == null) { // 根据业务需求选择:返回false或使用默认值(例如0) + value = 0; + add++; continue; //if (PlcConnect.PlcWrite2($"D{add}", 0, DataTypeEnum.UInt16).IsSuccess) // return false; @@ -159,7 +163,7 @@ namespace HighWayIot.Plc.PlcHelper } // 写入PLC并检查结果 - var resultbytes = BitConverter.GetBytes(valueToWrite); + byte[] resultbytes = BitConverter.GetBytes(valueToWrite); Array.Copy(resultbytes, 0, bytes, (add - 290) * 2, resultbytes.Length); //if (!PlcConnect.PlcWrite2($"D{add}", valueToWrite, DataTypeEnum.UInt16).IsSuccess) // return false; @@ -169,13 +173,17 @@ namespace HighWayIot.Plc.PlcHelper return bytes; } + #endregion + + #region 读取 + /// /// 从PLC中读取数据 /// public List DownLoadFormPlc(ref ZxRecipeParaEntity paraEntity) { //一次性读取 - OperateResult result = PlcConnect.MelsecInstance2.Read("D290", 120); + OperateResult result = PlcConnect.ReadByte2("D290", 120); byte[] data; if (result.IsSuccess) { @@ -187,7 +195,7 @@ namespace HighWayIot.Plc.PlcHelper } //读取SPEC编号 - paraEntity.SpecCode = PlcConnect.MelsecInstance2.ReadUInt32("D206").ToString(); + paraEntity.SpecCode = PlcConnect.ReadUInt322("D206").Content.ToString(); //读取SPEC名称 paraEntity.SpecName = PlcConnect.MelsecInstance2.ByteTransform.TransString(data, 0, 10, Encoding.ASCII); @@ -217,7 +225,7 @@ namespace HighWayIot.Plc.PlcHelper } /// - /// 分类工位循环写入 + /// 分类工位循环读取 /// /// /// @@ -262,5 +270,7 @@ namespace HighWayIot.Plc.PlcHelper return entity; } + + #endregion } } diff --git a/HighWayIot.Plc/PlcHelper/RecipeSignal.cs b/HighWayIot.Plc/PlcHelper/RecipeSignal.cs index 334626d..e974c7f 100644 --- a/HighWayIot.Plc/PlcHelper/RecipeSignal.cs +++ b/HighWayIot.Plc/PlcHelper/RecipeSignal.cs @@ -18,7 +18,7 @@ namespace HighWayIot.Plc.PlcHelper { Dictionary result = new Dictionary(); - OperateResult operateResult = PlcConnect.MelsecInstance2.Read("B991", 8); + OperateResult operateResult = PlcConnect.ReadByte2("B901", 8); if (!operateResult.IsSuccess) { @@ -35,7 +35,7 @@ namespace HighWayIot.Plc.PlcHelper boolIndex++; } - for (int i = 0x941 - 0x941; i < 0x97E - 0x941 + 1; i++) + for (int i = 0x941 - 0x901; i < 0x97E - 0x901 + 1; i++) { result.Add(boolIndex, bytes[i / 8].GetBoolByIndex(i % 8)); boolIndex++; diff --git a/HighWayIot.Plc/PlcHelper/TransferSingal.cs b/HighWayIot.Plc/PlcHelper/TransferSingal.cs index cca4105..85accbe 100644 --- a/HighWayIot.Plc/PlcHelper/TransferSingal.cs +++ b/HighWayIot.Plc/PlcHelper/TransferSingal.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace HighWayIot.Plc.PlcHelper { /// - /// 中专信号点位读写 + /// 中专信号点位读写(暂时米用) /// public class TransferSingal { @@ -25,19 +25,19 @@ namespace HighWayIot.Plc.PlcHelper switch (stationNo) { case 1: - result = PlcConnect.MelsecInstance2.Write("B201", true).IsSuccess; + result = PlcConnect.PlcWrite2("B201", true, DataTypeEnum.Bool).IsSuccess; break; case 2: - result = PlcConnect.MelsecInstance2.Write("B202", true).IsSuccess; + result = PlcConnect.PlcWrite2("B202", true, DataTypeEnum.Bool).IsSuccess; break; case 3: - result = PlcConnect.MelsecInstance2.Write("B203", true).IsSuccess; + result = PlcConnect.PlcWrite2("B203", true, DataTypeEnum.Bool).IsSuccess; break; case 4: - result = PlcConnect.MelsecInstance2.Write("B205", true).IsSuccess; + result = PlcConnect.PlcWrite2("B205", true, DataTypeEnum.Bool).IsSuccess; break; case 5: - result = PlcConnect.MelsecInstance2.Write("B207", true).IsSuccess; + result = PlcConnect.PlcWrite2("B207", true, DataTypeEnum.Bool).IsSuccess; break; default: break; @@ -59,19 +59,19 @@ namespace HighWayIot.Plc.PlcHelper switch (stationNo) { case 1: - result = PlcConnect.MelsecInstance2.Write("B211", true).IsSuccess; + result = PlcConnect.PlcWrite2("B211", true, DataTypeEnum.Bool).IsSuccess; break; case 2: - result = PlcConnect.MelsecInstance2.Write("B212", true).IsSuccess; + result = PlcConnect.PlcWrite2("B212", true, DataTypeEnum.Bool).IsSuccess; break; case 3: - result = PlcConnect.MelsecInstance2.Write("B213", true).IsSuccess; + result = PlcConnect.PlcWrite2("B213", true, DataTypeEnum.Bool).IsSuccess; break; case 4: - result = PlcConnect.MelsecInstance2.Write("B215", true).IsSuccess; + result = PlcConnect.PlcWrite2("B215", true, DataTypeEnum.Bool).IsSuccess; break; case 5: - result = PlcConnect.MelsecInstance2.Write("B217", true).IsSuccess; + result = PlcConnect.PlcWrite2("B217", true, DataTypeEnum.Bool).IsSuccess; break; default: break; @@ -86,7 +86,7 @@ namespace HighWayIot.Plc.PlcHelper /// 第一个Byte数组是第二个Byte数组是开始横裁信号,第三个是结束横裁信号 public bool[][] ReadDrumReadyAndCountReadySignal() { - OperateResult operateResult = PlcConnect.MelsecInstance2.Read("B980", 3); + OperateResult operateResult = PlcConnect.ReadByte2("B980", 3); if (!operateResult.IsSuccess) { @@ -123,7 +123,7 @@ namespace HighWayIot.Plc.PlcHelper /// public bool[][] ReadMonitorSingal() { - OperateResult operateResult = PlcConnect.MelsecInstance2.Read("B9B1", 5); + OperateResult operateResult = PlcConnect.ReadByte2("B9B1", 5); if (!operateResult.IsSuccess) { @@ -150,7 +150,7 @@ namespace HighWayIot.Plc.PlcHelper /// public List ReadStationRecipeInfo() { - OperateResult operateResult = PlcConnect.MelsecInstance2.Read("W950", 80); + OperateResult operateResult = PlcConnect.ReadByte2("W950", 80); if (!operateResult.IsSuccess) { diff --git a/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs b/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs index 7eff691..c66cafe 100644 --- a/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs +++ b/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs @@ -3,6 +3,7 @@ using HighWayIot.Plc.PlcEntity; using HslCommunication; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -28,12 +29,14 @@ namespace HighWayIot.Plc.PlcHelper //选择是小车的哪个点位 point += rgvStationNo - 1; - - bool result = PlcConnect.MelsecInstance2.Write($"B{point.ToString("X")}", true).IsSuccess; - if (result) - { - LogHelper.Instance.Info($"B{point.ToString("X")} 点置True"); - } + //Stopwatch sw = new Stopwatch(); + //sw.Start(); + bool result = PlcConnect.PlcWrite2($"B{point.ToString("X")}", true, DataTypeEnum.Bool).IsSuccess; + //sw.Stop(); + //if (result) + //{ + // LogHelper.Instance.Info($"B{point.ToString("X")} 点置True 点写入耗时[{sw.ElapsedMilliseconds}]"); + //} return result; } @@ -43,8 +46,11 @@ namespace HighWayIot.Plc.PlcHelper public bool[] ReadStationSingal() { bool[] result = new bool[17]; - - OperateResult PlcResult = PlcConnect.MelsecInstance2.Read("B230", 2); + //Stopwatch sw = new Stopwatch(); + //sw.Start(); + OperateResult PlcResult = PlcConnect.ReadByte2("B230", 2); + //sw.Stop(); + //LogHelper.Instance.Info($"工位识别 字段读取耗时[{sw.ElapsedMilliseconds}]"); byte[] data = PlcResult.Content; diff --git a/HighWayIot.Repository/domain/ExportTableEntity.cs b/HighWayIot.Repository/domain/ExportTableEntity.cs index 9f5cdce..9c1f6ec 100644 --- a/HighWayIot.Repository/domain/ExportTableEntity.cs +++ b/HighWayIot.Repository/domain/ExportTableEntity.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -14,116 +15,139 @@ namespace HighWayIot.Repository.domain /// /// 成品代号 /// + [Description("成品代号")] public string RecipeCode { get; set; } = string.Empty; /// /// 标称尺度 /// + [Description("标称尺度")] public string RecipeName { get; set; } = string.Empty; - + /// /// SPEC编号 /// + [Description("SPEC编号")] public string SpecCode { get; set; } = string.Empty; /// - /// SPEC规格 + /// SPEC规格 /// + [Description("SPEC规格")] public string SpecName { get; set; } = string.Empty; /// /// 开始时间 /// + [Description("开始时间")] public string StartTime { get; set; } = string.Empty; /// /// 基部胶胶号 /// + [Description("基部胶胶号")] public string BaseRubName { get; set; } = string.Empty; /// /// 基部胶厚度 - /// + /// /// 基部胶宽度 - /// + /// /// 基部胶层数 /// + [Description("基部胶层数")] public string BaseRubLayer { get; set; } = string.Empty; /// /// 基部胶完成时间 /// + [Description("基部胶完成时间")] public string BaseRubFinishTime { get; set; } = string.Empty; /// /// 中层胶胶号 /// + [Description("中层胶胶号")] public string MidRubName { get; set; } = string.Empty; /// /// 中层胶厚度 /// + [Description("中层胶厚度")] public string MidRubThickness { get; set; } = string.Empty; /// /// 中层胶宽度 /// + [Description("中层胶宽度")] public string MidRubWidth { get; set; } = string.Empty; /// /// 中层胶层数 /// + [Description("中层胶层数")] public string MidRubLayer { get; set; } = string.Empty; /// /// 中层胶完成时间 /// + [Description("中层胶完成时间")] public string MidRubFinishTime { get; set; } = string.Empty; /// /// 胎面胶胶号 /// + [Description("胎面胶胶号")] public string FaceRubName { get; set; } = string.Empty; /// /// 胎面胶厚度 /// + [Description("胎面胶厚度")] public string FaceRubThickness { get; set; } = string.Empty; /// - /// 胎面胶宽度 + /// 胎面胶厚度 /// - public string FaceRubWidth1 { get; set; } = string.Empty; + [Description("胎面胶层数")] + public string FaceRubLayer { get; set; } = string.Empty; /// - /// 胎边胶宽度 - /// - public string FaceRubWidth2 { get; set; } = string.Empty; + /// 胎面胶宽度 + /// /// 生胎完成时间 /// + [Description("生胎完成时间")] public string FaceRubFinishTime { get; set; } = string.Empty; /// /// 生胎宽度(胎面胶宽度 +(厚度*2)) 无中层胶就等于胎面胶宽度 /// + [Description("生胎宽度")] public string RawTireWidth { get; set; } = string.Empty; - + /// /// 生胎重量 /// + [Description("生胎重量")] public string RawTireWeight { get; set; } = string.Empty; /// /// 复重重量 /// + [Description("复重重量")] public string RepeatWeight { get; set; } = string.Empty; } } diff --git a/HighWayIot.Repository/domain/ZxDailyReportEntity.cs b/HighWayIot.Repository/domain/ZxDailyReportEntity.cs index cfef080..98016bf 100644 --- a/HighWayIot.Repository/domain/ZxDailyReportEntity.cs +++ b/HighWayIot.Repository/domain/ZxDailyReportEntity.cs @@ -110,6 +110,13 @@ namespace HighWayIot.Repository.domain [SugarColumn(ColumnName = "face_end_time")] public DateTime? FaceEndTime { get; set; } + /// + /// 备 注:复重重量 + /// 默认值: + /// + [SugarColumn(ColumnName = "repeat_weight")] + public int? RepeatWeight { get; set; } + /// /// 备 注:是否已完成(0未完成 1完成 2中止) /// 默认值: diff --git a/HighWayIot.Repository/domain/ZxWeightEntity.cs b/HighWayIot.Repository/domain/ZxWeightEntity.cs index 95cf811..fc9c251 100644 --- a/HighWayIot.Repository/domain/ZxWeightEntity.cs +++ b/HighWayIot.Repository/domain/ZxWeightEntity.cs @@ -67,6 +67,13 @@ namespace Models /// [SugarColumn(ColumnName = "set_width_2")] public decimal? SetWidth2 { get; set; } + + /// + /// 备 注:宽度3 + /// 默认值: + /// + [SugarColumn(ColumnName = "set_width_3")] + public decimal? SetWidth3 { get; set; } /// /// 备 注:层数 @@ -81,6 +88,13 @@ namespace Models /// [SugarColumn(ColumnName = "set_layer_2")] public int? SetLayer2 { get; set; } + + /// + /// 备 注:层数3 + /// 默认值: + /// + [SugarColumn(ColumnName = "set_layer_3")] + public int? SetLayer3 { get; set; } /// /// 备 注:重量 diff --git a/HighWayIot.Repository/service/SysLogService.cs b/HighWayIot.Repository/service/SysLogService.cs index 739b8a0..b7e00d6 100644 --- a/HighWayIot.Repository/service/SysLogService.cs +++ b/HighWayIot.Repository/service/SysLogService.cs @@ -67,5 +67,6 @@ namespace HighWayIot.Repository.service return false; } } + } } diff --git a/HighWayIot.Repository/service/ZxRecipeParaService.cs b/HighWayIot.Repository/service/ZxRecipeParaService.cs index ed19cc4..71bf57e 100644 --- a/HighWayIot.Repository/service/ZxRecipeParaService.cs +++ b/HighWayIot.Repository/service/ZxRecipeParaService.cs @@ -116,6 +116,24 @@ namespace HighWayIot.Repository.service } } + /// + /// ID删除配方字段信息 + /// + /// + /// + public bool DeleteRecipeParaInfoByRecipeCode(string recipeCode) + { + try + { + return _repository.Delete(x => x.RecipeCode == recipeCode); + } + catch (Exception ex) + { + log.Error("配方字段信息删除异常", ex); + return false; + } + } + /// /// 清除脏数据 /// diff --git a/HighWayIot.Repository/service/ZxRecipePositionParaService.cs b/HighWayIot.Repository/service/ZxRecipePositionParaService.cs index c82788d..f4052ad 100644 --- a/HighWayIot.Repository/service/ZxRecipePositionParaService.cs +++ b/HighWayIot.Repository/service/ZxRecipePositionParaService.cs @@ -135,6 +135,24 @@ namespace HighWayIot.Repository.service } } + /// + /// ID删除工位配方字段信息 + /// + /// + /// + public bool DeleteRecipePositionParaInfoByRecipeCode(string recipeCode) + { + try + { + return _repository.Delete(x => x.RecipeCode == recipeCode); + } + catch (Exception ex) + { + log.Error("工位配方字段信息删除异常", ex); + return false; + } + } + /// /// 清除脏数据 /// diff --git a/HighWayIot.Repository/service/ZxRecipeService.cs b/HighWayIot.Repository/service/ZxRecipeService.cs index 2c6f7f1..e207c82 100644 --- a/HighWayIot.Repository/service/ZxRecipeService.cs +++ b/HighWayIot.Repository/service/ZxRecipeService.cs @@ -82,25 +82,6 @@ namespace HighWayIot.Repository.service } } - /// - /// 根据成品代号查询条配方参数 - /// - /// - /// - public ZxRecipeEntity GetSingleInfoByRecipeCode(string recipeCode) - { - try - { - ZxRecipeEntity entity = _repository.GetSingle(x => x.RecipeCode == recipeCode && x.IsDeleted == false); - return entity; - } - catch (Exception ex) - { - log.Error("根据一个成品代号查询到多条配方信息", ex); - return null; - } - } - /// /// 获取所有配方名称 /// diff --git a/HighWayIot.Repository/service/ZxWeightService.cs b/HighWayIot.Repository/service/ZxWeightService.cs index d641aa1..866a9f4 100644 --- a/HighWayIot.Repository/service/ZxWeightService.cs +++ b/HighWayIot.Repository/service/ZxWeightService.cs @@ -25,6 +25,24 @@ namespace HighWayIot.Repository.service private LogHelper log = LogHelper.Instance; Repository _repository => new Repository("sqlserver"); + /// + /// 查询所有称重信息 + /// + /// + public List GetWeightInfos() + { + try + { + List entity = _repository.GetList(x => x.IsDeleted == false); + return entity; + } + catch (Exception ex) + { + log.Error("称量信息获取异常", ex); + return null; + } + } + /// /// 根据配方编号查询称量信息 /// diff --git a/HighWayIot.Rfid/RfidDataAnalyse.cs b/HighWayIot.Rfid/RfidDataAnalyse.cs index 17d391c..9673f41 100644 --- a/HighWayIot.Rfid/RfidDataAnalyse.cs +++ b/HighWayIot.Rfid/RfidDataAnalyse.cs @@ -80,9 +80,9 @@ namespace HighWayIot.Rfid { Array.Copy(data, index, EPCData.EPC, 0, 12); } - catch + catch (Exception ex) { - + Log4net.LogHelper.Instance.Error(ex.Message); return null; } index += 12; @@ -124,5 +124,15 @@ namespace HighWayIot.Rfid uint result = BitConverter.ToUInt32(data, 0); return result; } + + /// + /// 发送功率设置包 + /// + /// + /// + public byte[] Send42H(int power) + { + return new byte[0]; + } } } diff --git a/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj b/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj index 487d403..c323ccd 100644 --- a/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj +++ b/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj @@ -36,22 +36,22 @@ ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll - - ..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll + + ..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll - - ..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll + + ..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll - - ..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll + + ..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll - - ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll - - ..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll + + ..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll diff --git a/HighWayIot.TouchSocket/app.config b/HighWayIot.TouchSocket/app.config index 9c003b0..6e60b15 100644 --- a/HighWayIot.TouchSocket/app.config +++ b/HighWayIot.TouchSocket/app.config @@ -16,15 +16,15 @@ - + - + - + diff --git a/HighWayIot.TouchSocket/packages.config b/HighWayIot.TouchSocket/packages.config index 5bc89d6..a22d9c4 100644 --- a/HighWayIot.TouchSocket/packages.config +++ b/HighWayIot.TouchSocket/packages.config @@ -1,11 +1,11 @@  - - - - - + + + + + \ No newline at end of file diff --git a/HighWayIot.Winform/App.config b/HighWayIot.Winform/App.config index 601d9fb..2508d21 100644 --- a/HighWayIot.Winform/App.config +++ b/HighWayIot.Winform/App.config @@ -15,7 +15,7 @@ - + - + - + - + + + + + diff --git a/HighWayIot.Winform/Business/GeneralUtils.cs b/HighWayIot.Winform/Business/GeneralUtils.cs index be0a34a..f5c8804 100644 --- a/HighWayIot.Winform/Business/GeneralUtils.cs +++ b/HighWayIot.Winform/Business/GeneralUtils.cs @@ -2,11 +2,13 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Data; using System.Linq; using System.Net; using System.Reflection; using System.Security.Cryptography; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace HighWayIot.Winform.Business @@ -125,7 +127,7 @@ namespace HighWayIot.Winform.Business /// public static string DateTimeToString(DateTime? dateTimeStart, DateTime? dateTimeEnd) { - if(dateTimeEnd == null || dateTimeStart == null) + if (dateTimeEnd == null || dateTimeStart == null) { return string.Empty; } @@ -145,5 +147,6 @@ namespace HighWayIot.Winform.Business return result; } + } } diff --git a/HighWayIot.Winform/Business/RecipeSendBusiness.cs b/HighWayIot.Winform/Business/RecipeSendBusiness.cs index d6ef5d3..921a00e 100644 --- a/HighWayIot.Winform/Business/RecipeSendBusiness.cs +++ b/HighWayIot.Winform/Business/RecipeSendBusiness.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; using System.Xml.Schema; using Timer = System.Threading.Timer; @@ -35,7 +36,7 @@ namespace HighWayIot.Winform.Business public RecipeSendBusiness() { - //GetSchedulingTimer = new Timer(new System.Threading.TimerCallback(ReadSignal), null, 0, 1000); + GetSchedulingTimer = new Timer(new System.Threading.TimerCallback(ReadSignal), null, 0, 1500); } /// @@ -51,51 +52,72 @@ namespace HighWayIot.Winform.Business return; } - foreach (var item in a) + int destinationVulcanizationNo; + var ares = a.Where(x => x.Value == true).ToList(); + if (ares.Count == 1) { - if (item.Value) + destinationVulcanizationNo = ares[0].Key; + } + else + { + if(ares.Count > 1) { - var schedulingInfo = zxSchedulingService.GetSchedulingInfo(); - string recipeNo; - ZxRecipeParaEntity recipeParaInfo; - List zxRecipePositionParaEntities; - if ((item.Key + 1) <= 62) - { - recipeNo = schedulingInfo.Single(x => x.Id == item.Key + 1).RecipeCode1; - recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault(); - zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo); - if (recipeParaInfo == null) - { - LogHelper.Instance.Error("配方信息获取失败"); - return; - } - if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities)) - { - PlcConnect.MelsecInstance2.Write($"B{(item.Key + 0x901).ToString("X")}", false); - int deviceNo = schedulingInfo.Single(x => x.Id == item.Key + 1).DeviceNo ?? 0; - MonitorInsert(recipeNo, $"{deviceNo}上模"); - } - } - else - { - recipeNo = schedulingInfo.Single(x => x.Id == item.Key + 1).RecipeCode2; - recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault(); - zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo); - if (recipeParaInfo == null) - { - LogHelper.Instance.Error("配方信息获取失败"); - return; - } - if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities)) - { - PlcConnect.MelsecInstance2.Write($"B{(item.Key + 0x941).ToString("X")}", false); - int deviceNo = schedulingInfo.Single(x => x.Id == item.Key + 1 - 62).DeviceNo ?? 0; - MonitorInsert(recipeNo, $"{deviceNo}下模"); - } - } + LogHelper.Instance.Error($"排程信号True值不唯一 {string.Join(", " , ares.Select(x => x.Key).ToList())}"); + } + return; + } + + var schedulingInfo = zxSchedulingService.GetSchedulingInfo(); + string recipeNo; + ZxRecipeParaEntity recipeParaInfo; + List zxRecipePositionParaEntities; + if ((destinationVulcanizationNo + 1) <= 62) + { + recipeNo = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1).RecipeCode1; + recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault(); + zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo); + if (recipeParaInfo == null) + { + LogHelper.Instance.Error("配方信息获取失败"); + return; + } + if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities)) + { + PlcConnect.PlcWrite2($"B{(destinationVulcanizationNo + 0x901).ToString("X")}", false, DataTypeEnum.Bool); + int deviceNo = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1).DeviceNo ?? 0; + //MonitorInsert(recipeNo, $"{deviceNo}上模"); + LogHelper.Instance.Info($"配方上传成功,配方号:{recipeNo},模具号:{deviceNo}上模"); + } + else + { + LogHelper.Instance.Error("配方上传失败"); return; } } + else + { + recipeNo = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1 - 62).RecipeCode2; + recipeParaInfo = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(recipeNo).FirstOrDefault(); + zxRecipePositionParaEntities = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == recipeNo); + if (recipeParaInfo == null) + { + LogHelper.Instance.Error("配方信息获取失败"); + return; + } + if (recipeParaHelper.UploadToPLC(recipeParaInfo, zxRecipePositionParaEntities)) + { + PlcConnect.PlcWrite2($"B{(destinationVulcanizationNo - 62 + 0x941).ToString("X")}", false, DataTypeEnum.Bool); + int deviceNo = schedulingInfo.Single(x => x.Id == destinationVulcanizationNo + 1 - 62).DeviceNo ?? 0; + //MonitorInsert(recipeNo, $"{deviceNo}下模"); + LogHelper.Instance.Info($"配方上传成功,配方号:{recipeNo},模具号:{deviceNo}下模"); + } + else + { + LogHelper.Instance.Error("配方上传失败"); + return; + } + } + } /// @@ -118,6 +140,7 @@ namespace HighWayIot.Winform.Business RecipeCode = recipeEntity.RecipeCode, SpecCode = recipeEntity.RecipeSpecCode, DeviceNo = RecipeNeededVehicleNo, + RawTireWeight = (int)ZxRecipeParaService.Instance.GetRecipeParaInfoByRecipeCode(recipeCode).FirstOrDefault()?.TireWeight, IsDone = 0 }; diff --git a/HighWayIot.Winform/Business/TCPClientFactory.cs b/HighWayIot.Winform/Business/TCPClientFactory.cs index a6086bf..84b846b 100644 --- a/HighWayIot.Winform/Business/TCPClientFactory.cs +++ b/HighWayIot.Winform/Business/TCPClientFactory.cs @@ -66,6 +66,11 @@ namespace HighWayIot.Winform.Business /// private Timer _heartbeatTimer; + /// + /// 锁对象 + /// + private static readonly object _heartBeatLocker = new object(); + /// /// 工位识别历史记录 /// @@ -84,6 +89,7 @@ namespace HighWayIot.Winform.Business public void ReciveDataRoute(byte[] bytes, string ip) { BaseReciveDataEntity reciveData = BaseRFIDDataAnalyse.BaseReceiveAnalyse(bytes); + if (reciveData == null) { return; @@ -158,7 +164,7 @@ namespace HighWayIot.Winform.Business // return; // } //} - ///写入对应的PLC信号 + //写入对应的PLC信号 if (_workStationHelper.WriteStationSingal(stationNo, vehicleNo)) { ////写入成功后记录,上次已写入了该点位,不继续写入 @@ -170,7 +176,7 @@ namespace HighWayIot.Winform.Business //{ // StationRecord.Add(stationNo, vehicleNo); //} - LogHelper.Instance.RfidLog($"{workstationNo}工位, {deviceNo}号车 [{DateTime.Now.ToString("yy-MM-dd HH:mm:ss:fff")}]"); + LogHelper.Instance.RfidLog($"{workstationNo}工位, {deviceNo}号车 写入成功[{DateTime.Now.ToString("yy-MM-dd HH:mm:ss:fff")}]"); } else { diff --git a/HighWayIot.Winform/Business/WorkStationBusiness.cs b/HighWayIot.Winform/Business/WorkStationBusiness.cs index 6044827..c6c52b7 100644 --- a/HighWayIot.Winform/Business/WorkStationBusiness.cs +++ b/HighWayIot.Winform/Business/WorkStationBusiness.cs @@ -86,6 +86,7 @@ namespace HighWayIot.Winform.Business { _touchSocketTcpClient.CreateTcpClient(setting.RfidIp, "20108"); _touchSocketTcpClient.Send(setting.RfidIp, _RfidDataAnalyse.SendBFH(3)); + // _touchSocketTcpClient.Send(setting.RfidIp, _RfidDataAnalyse.Send) }); } diff --git a/HighWayIot.Winform/HighWayIot.Winform.csproj b/HighWayIot.Winform/HighWayIot.Winform.csproj index 994abae..3b2d513 100644 --- a/HighWayIot.Winform/HighWayIot.Winform.csproj +++ b/HighWayIot.Winform/HighWayIot.Winform.csproj @@ -12,6 +12,22 @@ 512 true true + false + D:\WorkCode\DLML-SCADA\publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 1 + 1.0.0.%2a + false + true + true AnyCPU @@ -30,17 +46,96 @@ bin\Release\ TRACE prompt - 4 + 2 + + 93BA197982FA90C2B1881421690AC335C9DA5029 + + + HighWayIot.Winform_TemporaryKey.pfx + + + true + + + true + + + true + + + ..\packages\BouncyCastle.Cryptography.2.3.1\lib\net461\BouncyCastle.Cryptography.dll + + + ..\packages\Enums.NET.4.0.1\lib\net45\Enums.NET.dll + + + ..\packages\ExtendedNumerics.BigDecimal.2025.1001.2.129\lib\net48\ExtendedNumerics.BigDecimal.dll + ..\HighWayIot.Library\HslCommunication.dll + + ..\packages\SharpZipLib.1.4.2\lib\netstandard2.0\ICSharpCode.SharpZipLib.dll + + + ..\packages\MathNet.Numerics.Signed.5.0.0\lib\net48\MathNet.Numerics.dll + + + ..\packages\Microsoft.IO.RecyclableMemoryStream.3.0.0\lib\netstandard2.0\Microsoft.IO.RecyclableMemoryStream.dll + + + ..\packages\NPOI.2.7.3\lib\net472\NPOI.Core.dll + + + ..\packages\NPOI.2.7.3\lib\net472\NPOI.OOXML.dll + + + ..\packages\NPOI.2.7.3\lib\net472\NPOI.OpenXml4Net.dll + + + ..\packages\NPOI.2.7.3\lib\net472\NPOI.OpenXmlFormats.dll + + + ..\packages\SixLabors.Fonts.1.0.1\lib\netstandard2.0\SixLabors.Fonts.dll + + + ..\packages\SixLabors.ImageSharp.2.1.10\lib\net472\SixLabors.ImageSharp.dll + + + ..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll + + + + + ..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + + + + ..\packages\System.Security.Cryptography.Pkcs.8.0.1\lib\net462\System.Security.Cryptography.Pkcs.dll + + + ..\packages\System.Security.Cryptography.Xml.8.0.2\lib\net462\System.Security.Cryptography.Xml.dll + + + ..\packages\System.Text.Encoding.CodePages.5.0.0\lib\net461\System.Text.Encoding.CodePages.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll + @@ -307,6 +402,8 @@ UserUpDateForm.cs + + SettingsSingleFileGenerator Settings.Designer.cs @@ -373,5 +470,17 @@ Always + + + False + Microsoft .NET Framework 4.8 %28x86 和 x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ No newline at end of file diff --git a/HighWayIot.Winform/MainForm/BaseForm.Designer.cs b/HighWayIot.Winform/MainForm/BaseForm.Designer.cs index fd87690..b042ba5 100644 --- a/HighWayIot.Winform/MainForm/BaseForm.Designer.cs +++ b/HighWayIot.Winform/MainForm/BaseForm.Designer.cs @@ -50,8 +50,10 @@ namespace HighWayIot.Winform.MainForm this.MaterialConfigStripItem = new System.Windows.Forms.ToolStripMenuItem(); this.MaterialTypeConfigStripItem = new System.Windows.Forms.ToolStripMenuItem(); this.RecipeConfigStripItem = new System.Windows.Forms.ToolStripMenuItem(); - this.TestMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.rToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.rFID参数配置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.机台物料信息绑定ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.TestMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.UserControlTabs = new System.Windows.Forms.TabControl(); this.ClosePageButton = new System.Windows.Forms.Button(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); @@ -62,16 +64,12 @@ namespace HighWayIot.Winform.MainForm this.SplitLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); this.LogInformationToolStrip = new System.Windows.Forms.ToolStripStatusLabel(); this.SplitLabel3 = new System.Windows.Forms.ToolStripStatusLabel(); - this.Label1 = new System.Windows.Forms.ToolStripStatusLabel(); - this.OpenMixStateLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.Label2 = new System.Windows.Forms.ToolStripStatusLabel(); this.MolderStateLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.SplitLabel4 = new System.Windows.Forms.ToolStripStatusLabel(); this.StripLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); this.TimeStripLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.TimeDisplayTimer = new System.Windows.Forms.Timer(this.components); - this.rFID参数配置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.机台物料信息绑定ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.MainMenu.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); @@ -225,14 +223,6 @@ namespace HighWayIot.Winform.MainForm this.RecipeConfigStripItem.Text = "配方管理"; this.RecipeConfigStripItem.Click += new System.EventHandler(this.StripMenuItemClick); // - // TestMenuItem - // - this.TestMenuItem.Image = global::HighWayIot.Winform.Properties.Resources.PLC; - this.TestMenuItem.Name = "TestMenuItem"; - this.TestMenuItem.Size = new System.Drawing.Size(105, 22); - this.TestMenuItem.Text = "PLC测试页面"; - this.TestMenuItem.Click += new System.EventHandler(this.StripMenuItemClick); - // // rToolStripMenuItem // this.rToolStripMenuItem.Image = global::HighWayIot.Winform.Properties.Resources.加硫_03; @@ -241,6 +231,30 @@ namespace HighWayIot.Winform.MainForm this.rToolStripMenuItem.Text = "硫化排程"; this.rToolStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick); // + // rFID参数配置ToolStripMenuItem + // + this.rFID参数配置ToolStripMenuItem.Image = global::HighWayIot.Winform.Properties.Resources._165_RFID; + this.rFID参数配置ToolStripMenuItem.Name = "rFID参数配置ToolStripMenuItem"; + this.rFID参数配置ToolStripMenuItem.Size = new System.Drawing.Size(111, 22); + this.rFID参数配置ToolStripMenuItem.Text = "RFID参数配置"; + this.rFID参数配置ToolStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick); + // + // 机台物料信息绑定ToolStripMenuItem1 + // + this.机台物料信息绑定ToolStripMenuItem1.Image = global::HighWayIot.Winform.Properties.Resources.绑定; + this.机台物料信息绑定ToolStripMenuItem1.Name = "机台物料信息绑定ToolStripMenuItem1"; + this.机台物料信息绑定ToolStripMenuItem1.Size = new System.Drawing.Size(132, 22); + this.机台物料信息绑定ToolStripMenuItem1.Text = "机台物料信息绑定"; + this.机台物料信息绑定ToolStripMenuItem1.Click += new System.EventHandler(this.StripMenuItemClick); + // + // TestMenuItem + // + this.TestMenuItem.Image = global::HighWayIot.Winform.Properties.Resources.PLC; + this.TestMenuItem.Name = "TestMenuItem"; + this.TestMenuItem.Size = new System.Drawing.Size(105, 22); + this.TestMenuItem.Text = "PLC测试页面"; + this.TestMenuItem.Click += new System.EventHandler(this.StripMenuItemClick); + // // UserControlTabs // this.UserControlTabs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -279,8 +293,6 @@ namespace HighWayIot.Winform.MainForm this.SplitLabel2, this.LogInformationToolStrip, this.SplitLabel3, - this.Label1, - this.OpenMixStateLabel, this.Label2, this.MolderStateLabel, this.SplitLabel4, @@ -325,7 +337,7 @@ namespace HighWayIot.Winform.MainForm // LogInformationToolStrip // this.LogInformationToolStrip.Name = "LogInformationToolStrip"; - this.LogInformationToolStrip.Size = new System.Drawing.Size(1280, 17); + this.LogInformationToolStrip.Size = new System.Drawing.Size(1400, 17); this.LogInformationToolStrip.Spring = true; this.LogInformationToolStrip.Text = "message"; // @@ -335,18 +347,6 @@ namespace HighWayIot.Winform.MainForm this.SplitLabel3.Name = "SplitLabel3"; this.SplitLabel3.Size = new System.Drawing.Size(4, 17); // - // Label1 - // - this.Label1.Name = "Label1"; - this.Label1.Size = new System.Drawing.Size(89, 17); - this.Label1.Text = "开炼PLC状态:"; - // - // OpenMixStateLabel - // - this.OpenMixStateLabel.Name = "OpenMixStateLabel"; - this.OpenMixStateLabel.Size = new System.Drawing.Size(31, 17); - this.OpenMixStateLabel.Text = "N/A"; - // // Label2 // this.Label2.Name = "Label2"; @@ -382,22 +382,6 @@ namespace HighWayIot.Winform.MainForm this.TimeDisplayTimer.Interval = 1000; this.TimeDisplayTimer.Tick += new System.EventHandler(this.TimeDisplayTimer_Tick); // - // rFID参数配置ToolStripMenuItem - // - this.rFID参数配置ToolStripMenuItem.Image = global::HighWayIot.Winform.Properties.Resources._165_RFID; - this.rFID参数配置ToolStripMenuItem.Name = "rFID参数配置ToolStripMenuItem"; - this.rFID参数配置ToolStripMenuItem.Size = new System.Drawing.Size(111, 22); - this.rFID参数配置ToolStripMenuItem.Text = "RFID参数配置"; - this.rFID参数配置ToolStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick); - // - // 机台物料信息绑定ToolStripMenuItem1 - // - this.机台物料信息绑定ToolStripMenuItem1.Image = global::HighWayIot.Winform.Properties.Resources.绑定; - this.机台物料信息绑定ToolStripMenuItem1.Name = "机台物料信息绑定ToolStripMenuItem1"; - this.机台物料信息绑定ToolStripMenuItem1.Size = new System.Drawing.Size(132, 22); - this.机台物料信息绑定ToolStripMenuItem1.Text = "机台物料信息绑定"; - this.机台物料信息绑定ToolStripMenuItem1.Click += new System.EventHandler(this.StripMenuItemClick); - // // BaseForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -454,8 +438,6 @@ namespace HighWayIot.Winform.MainForm private ToolStripStatusLabel SplitLabel2; private ToolStripStatusLabel SplitLabel3; private ToolStripStatusLabel SplitLabel4; - private ToolStripStatusLabel Label1; - private ToolStripStatusLabel OpenMixStateLabel; private ToolStripStatusLabel Label2; private ToolStripStatusLabel MolderStateLabel; private ToolStripMenuItem rToolStripMenuItem; diff --git a/HighWayIot.Winform/MainForm/BaseForm.cs b/HighWayIot.Winform/MainForm/BaseForm.cs index 6f54554..2487f81 100644 --- a/HighWayIot.Winform/MainForm/BaseForm.cs +++ b/HighWayIot.Winform/MainForm/BaseForm.cs @@ -93,6 +93,7 @@ namespace HighWayIot.Winform.MainForm NowLoginUserName.Text = RoleBusiness.LoginUserName; UserPanelSwitch(typeof(MonitorMainPage), "监控主页面"); RoleControl(); + SqlLogHelper.AddLog($"用户[{RoleBusiness.LoginUserName}]登录成功"); WatchDogTimer = new System.Threading.Timer(WarchDogJudge, null, 0, 2000); // 每2秒执行一次 LogRefreshAction += (log) => { diff --git a/HighWayIot.Winform/Program.cs b/HighWayIot.Winform/Program.cs index 7021331..60ae8ab 100644 --- a/HighWayIot.Winform/Program.cs +++ b/HighWayIot.Winform/Program.cs @@ -50,7 +50,7 @@ namespace HighWayIot.Winform } catch(Exception ex) { - logger.Error("程序初始化异常", ex); + logger.Error("程序异常", ex); } } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.cs b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.cs index 445df91..e8c17e5 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.cs @@ -1,6 +1,7 @@ using HighWayIot.Repository.domain; using HighWayIot.Repository.service; using HighWayIot.Winform.Business; +using HighWayIot.Winform.UserControlPages.LogPages; using System; using System.Collections; using System.Collections.Generic; @@ -24,6 +25,8 @@ namespace HighWayIot.Winform.UserControlPages /// private ZxDailyReportService _zxDailyReportService = ZxDailyReportService.Instance; + private List dailyEntities = new List(); + /// /// datagridview 数据源 /// 必须使用BindingList, 如果使用LIST,无法实现更改,添加、删除数据源自动更新datagridview @@ -78,7 +81,8 @@ namespace HighWayIot.Winform.UserControlPages private void DataRefresh() { - List dailyEntities = + dailyEntities.Clear(); + this.dailyEntities = _zxDailyReportService.GetDailyReportInfos(x => x.StartTime >= SelectStartTime.Value && x.StartTime <= SelectEndTime.Value @@ -114,7 +118,12 @@ namespace HighWayIot.Winform.UserControlPages /// private void ExportTableButton_Click(object sender, EventArgs e) { - + ExportPreviewForm exportPreviewForm = new ExportPreviewForm(dailyEntities); + if (exportPreviewForm.ShowDialog() == DialogResult.OK) + { + //MessageBox.Show("导出成功"); + } } + } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.resx b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.resx index a36df43..b1a9187 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.resx +++ b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.resx @@ -150,37 +150,4 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.Designer.cs b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.Designer.cs index 01cd717..bbf38cc 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.Designer.cs @@ -28,19 +28,365 @@ /// private void InitializeComponent() { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.RecipeCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RecipeName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SpecCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SpecName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.StartTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.BaseRubName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.BaseRubThickness = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.BaseRubWidth = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.BaseRubLayer = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.BaseRubFinishTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MidRubName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MidRubThickness = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MidRubWidth = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MidRubLayer = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MidRubFinishTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.FaceRubName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.FaceRubThickness = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.FaceRubWidth = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.FaceRubLayer = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RawTireWidth = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RawTireFinishTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RawTireWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RepeatWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ExportButton = new System.Windows.Forms.Button(); + this.PathTextBox = new System.Windows.Forms.TextBox(); + this.PathSelectButton = new System.Windows.Forms.Button(); + this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // + // dataGridView1 + // + this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("新宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.RecipeCode, + this.RecipeName, + this.SpecCode, + this.SpecName, + this.StartTime, + this.BaseRubName, + this.BaseRubThickness, + this.BaseRubWidth, + this.BaseRubLayer, + this.BaseRubFinishTime, + this.MidRubName, + this.MidRubThickness, + this.MidRubWidth, + this.MidRubLayer, + this.MidRubFinishTime, + this.FaceRubName, + this.FaceRubThickness, + this.FaceRubWidth, + this.FaceRubLayer, + this.RawTireWidth, + this.RawTireFinishTime, + this.RawTireWeight, + this.RepeatWeight}); + this.dataGridView1.Cursor = System.Windows.Forms.Cursors.IBeam; + this.dataGridView1.EnableHeadersVisualStyles = false; + this.dataGridView1.Location = new System.Drawing.Point(-238, 193); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.RowHeadersVisible = false; + this.dataGridView1.RowTemplate.Height = 23; + this.dataGridView1.Size = new System.Drawing.Size(1904, 985); + this.dataGridView1.TabIndex = 0; + // + // RecipeCode + // + this.RecipeCode.DataPropertyName = "RecipeCode"; + this.RecipeCode.HeaderText = "成品代号"; + this.RecipeCode.Name = "RecipeCode"; + this.RecipeCode.Width = 59; + // + // RecipeName + // + this.RecipeName.DataPropertyName = "RecipeName"; + this.RecipeName.FillWeight = 230.1951F; + this.RecipeName.HeaderText = "标称尺度"; + this.RecipeName.Name = "RecipeName"; + this.RecipeName.Width = 59; + // + // SpecCode + // + this.SpecCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.SpecCode.DataPropertyName = "SpecCode"; + this.SpecCode.FillWeight = 244.9275F; + this.SpecCode.HeaderText = "SPEC编号"; + this.SpecCode.Name = "SpecCode"; + this.SpecCode.Width = 59; + // + // SpecName + // + this.SpecName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.SpecName.DataPropertyName = "SpecName"; + this.SpecName.FillWeight = 88.53656F; + this.SpecName.HeaderText = "SPEC规格"; + this.SpecName.Name = "SpecName"; + this.SpecName.Width = 59; + // + // StartTime + // + this.StartTime.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.StartTime.DataPropertyName = "StartTime"; + this.StartTime.FillWeight = 88.53656F; + this.StartTime.HeaderText = "开始时间"; + this.StartTime.Name = "StartTime"; + this.StartTime.Width = 59; + // + // BaseRubName + // + this.BaseRubName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.BaseRubName.DataPropertyName = "BaseRubName"; + this.BaseRubName.FillWeight = 88.53656F; + this.BaseRubName.HeaderText = "基部胶胶号"; + this.BaseRubName.Name = "BaseRubName"; + this.BaseRubName.Width = 71; + // + // BaseRubThickness + // + this.BaseRubThickness.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.BaseRubThickness.DataPropertyName = "BaseRubThickness"; + this.BaseRubThickness.FillWeight = 88.53656F; + this.BaseRubThickness.HeaderText = "基部胶厚度"; + this.BaseRubThickness.Name = "BaseRubThickness"; + this.BaseRubThickness.Width = 71; + // + // BaseRubWidth + // + this.BaseRubWidth.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.BaseRubWidth.DataPropertyName = "BaseRubWidth"; + this.BaseRubWidth.FillWeight = 88.53656F; + this.BaseRubWidth.HeaderText = "基部胶宽度"; + this.BaseRubWidth.Name = "BaseRubWidth"; + this.BaseRubWidth.Width = 77; + // + // BaseRubLayer + // + this.BaseRubLayer.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.BaseRubLayer.DataPropertyName = "BaseRubLayer"; + this.BaseRubLayer.FillWeight = 88.53656F; + this.BaseRubLayer.HeaderText = "基部胶层数"; + this.BaseRubLayer.Name = "BaseRubLayer"; + this.BaseRubLayer.Width = 77; + // + // BaseRubFinishTime + // + this.BaseRubFinishTime.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.BaseRubFinishTime.DataPropertyName = "BaseRubFinishTime"; + this.BaseRubFinishTime.FillWeight = 88.53656F; + this.BaseRubFinishTime.HeaderText = "基部胶完成时间"; + this.BaseRubFinishTime.Name = "BaseRubFinishTime"; + this.BaseRubFinishTime.Width = 95; + // + // MidRubName + // + this.MidRubName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.MidRubName.DataPropertyName = "MidRubName"; + this.MidRubName.FillWeight = 88.53656F; + this.MidRubName.HeaderText = "中层胶胶号"; + this.MidRubName.Name = "MidRubName"; + this.MidRubName.Width = 71; + // + // MidRubThickness + // + this.MidRubThickness.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.MidRubThickness.DataPropertyName = "MidRubThickness"; + this.MidRubThickness.FillWeight = 88.53656F; + this.MidRubThickness.HeaderText = "中层胶厚度"; + this.MidRubThickness.Name = "MidRubThickness"; + this.MidRubThickness.Width = 71; + // + // MidRubWidth + // + this.MidRubWidth.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.MidRubWidth.DataPropertyName = "MidRubWidth"; + this.MidRubWidth.FillWeight = 88.53656F; + this.MidRubWidth.HeaderText = "中层胶宽度"; + this.MidRubWidth.Name = "MidRubWidth"; + this.MidRubWidth.Width = 71; + // + // MidRubLayer + // + this.MidRubLayer.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.MidRubLayer.DataPropertyName = "MidRubLayer"; + this.MidRubLayer.FillWeight = 88.53656F; + this.MidRubLayer.HeaderText = "中层胶层数"; + this.MidRubLayer.Name = "MidRubLayer"; + this.MidRubLayer.Width = 71; + // + // MidRubFinishTime + // + this.MidRubFinishTime.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.MidRubFinishTime.DataPropertyName = "MidRubFinishTime"; + this.MidRubFinishTime.FillWeight = 88.53656F; + this.MidRubFinishTime.HeaderText = "中层胶完成时间"; + this.MidRubFinishTime.Name = "MidRubFinishTime"; + this.MidRubFinishTime.Width = 95; + // + // FaceRubName + // + this.FaceRubName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.FaceRubName.DataPropertyName = "FaceRubName"; + this.FaceRubName.FillWeight = 88.53656F; + this.FaceRubName.HeaderText = "胎面胶胶号"; + this.FaceRubName.Name = "FaceRubName"; + this.FaceRubName.Width = 71; + // + // FaceRubThickness + // + this.FaceRubThickness.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.FaceRubThickness.DataPropertyName = "FaceRubThickness"; + this.FaceRubThickness.FillWeight = 88.53656F; + this.FaceRubThickness.HeaderText = "胎面胶厚度"; + this.FaceRubThickness.Name = "FaceRubThickness"; + this.FaceRubThickness.Width = 71; + // + // FaceRubWidth + // + this.FaceRubWidth.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.FaceRubWidth.DataPropertyName = "FaceRubWidth"; + this.FaceRubWidth.FillWeight = 88.53656F; + this.FaceRubWidth.HeaderText = "胎面胶宽度"; + this.FaceRubWidth.Name = "FaceRubWidth"; + this.FaceRubWidth.Width = 71; + // + // FaceRubLayer + // + this.FaceRubLayer.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.FaceRubLayer.DataPropertyName = "(无)FaceRubLayer"; + this.FaceRubLayer.FillWeight = 88.53656F; + this.FaceRubLayer.HeaderText = "胎面胶层数"; + this.FaceRubLayer.Name = "FaceRubLayer"; + this.FaceRubLayer.Width = 71; + // + // RawTireWidth + // + this.RawTireWidth.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.RawTireWidth.DataPropertyName = "RawTireWidth"; + this.RawTireWidth.FillWeight = 88.53656F; + this.RawTireWidth.HeaderText = "生胎宽度"; + this.RawTireWidth.Name = "RawTireWidth"; + this.RawTireWidth.Width = 59; + // + // RawTireFinishTime + // + this.RawTireFinishTime.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.RawTireFinishTime.DataPropertyName = "RawTireFinishTime"; + this.RawTireFinishTime.FillWeight = 88.53656F; + this.RawTireFinishTime.HeaderText = "生胎完成时间"; + this.RawTireFinishTime.Name = "RawTireFinishTime"; + this.RawTireFinishTime.Width = 83; + // + // RawTireWeight + // + this.RawTireWeight.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.RawTireWeight.DataPropertyName = "RawTireWeight"; + this.RawTireWeight.FillWeight = 88.53656F; + this.RawTireWeight.HeaderText = "生胎重量"; + this.RawTireWeight.Name = "RawTireWeight"; + this.RawTireWeight.Width = 59; + // + // RepeatWeight + // + this.RepeatWeight.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.RepeatWeight.DataPropertyName = "RepeatWeight"; + this.RepeatWeight.FillWeight = 88.53656F; + this.RepeatWeight.HeaderText = "复重重量"; + this.RepeatWeight.Name = "RepeatWeight"; + this.RepeatWeight.Width = 59; + // + // ExportButton + // + this.ExportButton.Location = new System.Drawing.Point(9, 9); + this.ExportButton.Margin = new System.Windows.Forms.Padding(0); + this.ExportButton.Name = "ExportButton"; + this.ExportButton.Size = new System.Drawing.Size(90, 38); + this.ExportButton.TabIndex = 1; + this.ExportButton.Text = "导出为EXCEL"; + this.ExportButton.UseVisualStyleBackColor = true; + this.ExportButton.Click += new System.EventHandler(this.ExportButton_Click); + // + // PathTextBox + // + this.PathTextBox.Location = new System.Drawing.Point(102, 19); + this.PathTextBox.Name = "PathTextBox"; + this.PathTextBox.Size = new System.Drawing.Size(364, 21); + this.PathTextBox.TabIndex = 2; + // + // PathSelectButton + // + this.PathSelectButton.Location = new System.Drawing.Point(472, 18); + this.PathSelectButton.Name = "PathSelectButton"; + this.PathSelectButton.Size = new System.Drawing.Size(86, 23); + this.PathSelectButton.TabIndex = 3; + this.PathSelectButton.Text = "路径选择"; + this.PathSelectButton.UseVisualStyleBackColor = true; + this.PathSelectButton.Click += new System.EventHandler(this.PathSelectButton_Click); + // // ExportPreviewForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1904, 1041); + this.Controls.Add(this.PathSelectButton); + this.Controls.Add(this.PathTextBox); + this.Controls.Add(this.ExportButton); + this.Controls.Add(this.dataGridView1); this.Name = "ExportPreviewForm"; this.Text = "导出预览"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ExportPreviewForm_FormClosing); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); + this.PerformLayout(); } #endregion + + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.Button ExportButton; + private System.Windows.Forms.TextBox PathTextBox; + private System.Windows.Forms.Button PathSelectButton; + private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; + private System.Windows.Forms.DataGridViewTextBoxColumn RecipeCode; + private System.Windows.Forms.DataGridViewTextBoxColumn RecipeName; + private System.Windows.Forms.DataGridViewTextBoxColumn SpecCode; + private System.Windows.Forms.DataGridViewTextBoxColumn SpecName; + private System.Windows.Forms.DataGridViewTextBoxColumn StartTime; + private System.Windows.Forms.DataGridViewTextBoxColumn BaseRubName; + private System.Windows.Forms.DataGridViewTextBoxColumn BaseRubThickness; + private System.Windows.Forms.DataGridViewTextBoxColumn BaseRubWidth; + private System.Windows.Forms.DataGridViewTextBoxColumn BaseRubLayer; + private System.Windows.Forms.DataGridViewTextBoxColumn BaseRubFinishTime; + private System.Windows.Forms.DataGridViewTextBoxColumn MidRubName; + private System.Windows.Forms.DataGridViewTextBoxColumn MidRubThickness; + private System.Windows.Forms.DataGridViewTextBoxColumn MidRubWidth; + private System.Windows.Forms.DataGridViewTextBoxColumn MidRubLayer; + private System.Windows.Forms.DataGridViewTextBoxColumn MidRubFinishTime; + private System.Windows.Forms.DataGridViewTextBoxColumn FaceRubName; + private System.Windows.Forms.DataGridViewTextBoxColumn FaceRubThickness; + private System.Windows.Forms.DataGridViewTextBoxColumn FaceRubWidth; + private System.Windows.Forms.DataGridViewTextBoxColumn FaceRubLayer; + private System.Windows.Forms.DataGridViewTextBoxColumn RawTireWidth; + private System.Windows.Forms.DataGridViewTextBoxColumn RawTireFinishTime; + private System.Windows.Forms.DataGridViewTextBoxColumn RawTireWeight; + private System.Windows.Forms.DataGridViewTextBoxColumn RepeatWeight; } } \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.cs b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.cs index 2f57d0e..3959003 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.cs @@ -1,20 +1,312 @@ -using System; +using NPOI.HSSF.UserModel; +using NPOI.SS.UserModel; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; +using HighWayIot.Repository.domain; +using HighWayIot.Repository.service; +using Models; +using HighWayIot.Winform.Business; +using System.Reflection; namespace HighWayIot.Winform.UserControlPages.LogPages { public partial class ExportPreviewForm : Form { - public ExportPreviewForm() + private string _savePath = string.Empty; + + private List _zxDailyReportEntities; + + private List _exportTableEntities = new List(); + + private List _zxWeightEntities; + + private List _zxRecipeEntities; + + private ZxWeightService _zxWeightService = ZxWeightService.Instance; + + private ZxRecipeService _zxRecipeService = ZxRecipeService.Instance; + + private DataTable dataTable; + + public ExportPreviewForm(List entity) { + _zxDailyReportEntities = entity; + InitializeComponent(); + + Init(); } - } + + private void Init() + { + dataGridView1.AutoGenerateColumns = false; + + //查询所有称重信息 + _zxWeightEntities = _zxWeightService.GetWeightInfos(); + + //查询所有配方信息 + _zxRecipeEntities = _zxRecipeService.GetRecipeInfos(); + + //开始关联 生成报表 + foreach(ZxDailyReportEntity rawEntity in _zxDailyReportEntities) + { + ExportTableEntity exportTableEntity = new ExportTableEntity(); + ZxRecipeEntity recipeEntity = _zxRecipeEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode).FirstOrDefault(); + ZxWeightEntity baseWeight = _zxWeightEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode && x.MaterialType == "基部胶").FirstOrDefault(); + ZxWeightEntity midWeight = _zxWeightEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode && x.MaterialType == "缓冲胶").FirstOrDefault(); + ZxWeightEntity faceWeight = _zxWeightEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode && x.MaterialType == "胎面胶").FirstOrDefault(); + if (recipeEntity == null) + { + continue; + } + exportTableEntity.RecipeCode = rawEntity.RecipeCode; + exportTableEntity.RecipeName = rawEntity.RecipeName; + exportTableEntity.SpecCode = rawEntity.SpecCode; + exportTableEntity.SpecName = recipeEntity.RecipeSpecName; + exportTableEntity.StartTime = rawEntity.StartTime.ToString("yyyy-MM-dd hh:mm:ss"); + + //基部胶 + if (baseWeight != null) + { + exportTableEntity.BaseRubName = baseWeight.MaterialName; + exportTableEntity.BaseRubThickness = baseWeight.SetThickness.ToString(); + //基部胶宽度和层数(可能有两层 + if (baseWeight.SetLayer2 == 0 || baseWeight.SetLayer2 == null) + { + exportTableEntity.BaseRubWidth = baseWeight.SetWidth.ToString(); + exportTableEntity.BaseRubLayer = baseWeight.SetLayer.ToString(); + } + else + { + exportTableEntity.BaseRubWidth = $"{baseWeight.SetWidth}/{baseWeight.SetWidth2}"; + exportTableEntity.BaseRubLayer = $"{baseWeight.SetLayer}/{baseWeight.SetLayer2}"; + } + exportTableEntity.BaseRubFinishTime = GeneralUtils.DateTimeToString(rawEntity.StartTime, rawEntity.BaseEndTime); + } + + //中层胶 + if (midWeight != null) + { + exportTableEntity.MidRubName = midWeight.MaterialName; + exportTableEntity.MidRubThickness = midWeight.SetThickness.ToString(); + exportTableEntity.MidRubWidth = midWeight.SetWidth.ToString(); + exportTableEntity.MidRubLayer = midWeight.SetLayer.ToString(); + exportTableEntity.MidRubFinishTime = GeneralUtils.DateTimeToString(rawEntity.StartTime, rawEntity.MidEndTime); + } + + //胎面胶 + if (faceWeight != null) + { + exportTableEntity.FaceRubName = faceWeight.MaterialName; + exportTableEntity.FaceRubThickness = faceWeight.SetThickness.ToString(); + //胎面胶宽度和层数(可能有两层 + if (faceWeight.SetLayer2 == 0 || faceWeight.SetLayer2 == null) + { + exportTableEntity.FaceRubWidth = faceWeight.SetWidth.ToString(); + exportTableEntity.FaceRubLayer = faceWeight.SetLayer.ToString(); + } + else + { + exportTableEntity.FaceRubWidth = $"{faceWeight.SetWidth}/{faceWeight.SetWidth2}"; + exportTableEntity.FaceRubLayer = $"{faceWeight.SetLayer}/{faceWeight.SetLayer2}"; + } + exportTableEntity.FaceRubFinishTime = GeneralUtils.DateTimeToString(rawEntity.StartTime, rawEntity.FaceEndTime); + } + + exportTableEntity.RawTireWidth = (faceWeight.SetThickness * 2 + faceWeight.SetWidth).ToString(); + exportTableEntity.RawTireWeight = rawEntity.RawTireWeight.ToString(); + exportTableEntity.RepeatWeight = rawEntity.RepeatWeight.ToString(); + + + _exportTableEntities.Add(exportTableEntity); + } + + dataGridView1.DataSource = null; + dataGridView1.DataSource = _exportTableEntities; + + try + { + dataTable = ToDataTable(_exportTableEntities.ToArray()); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + /// + /// 路径选择按钮 + /// + /// + /// + private void PathSelectButton_Click(object sender, EventArgs e) + { + folderBrowserDialog1.Description = "请选择文件路径"; + + if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) + { + _savePath = folderBrowserDialog1.SelectedPath; + PathTextBox.Text = _savePath; + } + } + + private void ExportButton_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(PathTextBox.Text)) + { + MessageBox.Show("请先选择导出路径!"); + return; + } + ExportExcel(dataTable, _savePath); + this.Close(); + } + + /// + /// 导出Excel + /// + /// + public void ExportExcel(DataTable dt, string path) + { + try + { + //创建一个工作簿 + IWorkbook workbook = new HSSFWorkbook(); + + //创建一个 sheet 表 + ISheet sheet = workbook.CreateSheet(dt.TableName); + + //创建一行 + IRow rowH = sheet.CreateRow(0); + + //创建一个单元格 + ICell cell = null; + + //创建单元格样式 + ICellStyle cellStyle = workbook.CreateCellStyle(); + + //创建格式 + IDataFormat dataFormat = workbook.CreateDataFormat(); + + //设置为文本格式,也可以为 text,即 dataFormat.GetFormat("text"); + cellStyle.DataFormat = dataFormat.GetFormat("@"); + + //设置列名 + foreach (DataColumn col in dt.Columns) + { + //创建单元格并设置单元格内容 + rowH.CreateCell(col.Ordinal).SetCellValue(col.Caption); + + //设置单元格格式 + rowH.Cells[col.Ordinal].CellStyle = cellStyle; + } + + //写入数据 + for (int i = 0; i < dt.Rows.Count; i++) + { + //跳过第一行,第一行为列名 + IRow row = sheet.CreateRow(i + 1); + + for (int j = 0; j < dt.Columns.Count; j++) + { + cell = row.CreateCell(j); + cell.SetCellValue(dt.Rows[i][j].ToString()); + cell.CellStyle = cellStyle; + } + } + + //设置导出文件路径 + //string path = HttpContext.Current.Server.MapPath("Export/"); + + //设置新建文件路径及名称 + string savePath = $"{path}/203报表{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}.xls"; + + //创建文件 + FileStream file = new FileStream(savePath, FileMode.CreateNew, FileAccess.Write); + + //创建一个 IO 流 + MemoryStream ms = new MemoryStream(); + + //写入到流 + workbook.Write(ms); + + //转换为字节数组 + byte[] bytes = ms.ToArray(); + + file.Write(bytes, 0, bytes.Length); + file.Flush(); + + //还可以调用下面的方法,把流输出到浏览器下载 + //OutputClient(bytes); + + //释放资源 + bytes = null; + + ms.Close(); + ms.Dispose(); + + file.Close(); + file.Dispose(); + + workbook.Close(); + sheet = null; + workbook = null; + MessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void ExportPreviewForm_FormClosing(object sender, FormClosingEventArgs e) + { + this.DialogResult = DialogResult.OK; + } + + + /// + /// 实体类转dt + /// + /// + /// + /// + public DataTable ToDataTable(T[] entities) + { + DataTable dataTable = new DataTable(typeof(T).Name); + + PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance); + + foreach (PropertyInfo propInfo in properties) + { + // Get the Description attribute if it exists + var descriptionAttribute = propInfo.GetCustomAttribute(); + string columnName = descriptionAttribute != null ? descriptionAttribute.Description : propInfo.Name; + + dataTable.Columns.Add(columnName, propInfo.PropertyType); + } + + foreach (T entity in entities) + { + object[] values = new object[properties.Length]; + for (int i = 0; i < properties.Length; i++) + { + values[i] = properties[i].GetValue(entity); + } + + dataTable.Rows.Add(values); + } + + return dataTable; + } + } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.resx b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.resx index 1af7de1..43fdad8 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.resx +++ b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.resx @@ -117,4 +117,76 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + 17, 17 + \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.cs b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.cs index b75af9c..2365089 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.cs @@ -28,7 +28,7 @@ namespace HighWayIot.Winform.UserControlPages private void Init() { LogDataGridView.AutoGenerateColumns = false; - + SelectLogBeginTime.Value = DateTime.Now.AddMonths(-3); Lists = sysLogService.GetLogInfos(); LogDataGridView.DataSource = null; LogDataGridView.DataSource = Lists; diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.cs index 8081549..4379b6b 100644 --- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.cs +++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialAddForm.cs @@ -92,6 +92,7 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages MessageBox.Show("物料信息添加失败!"); return; } + SqlLogHelper.AddLog($"物料信息修添加成功 物料编号[{entity.MaterialCode}]"); this.Close(); this.Dispose(); diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.cs index 76b7633..d57df7b 100644 --- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.cs +++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialConfigPage.cs @@ -146,6 +146,7 @@ namespace HighWayIot.Winform.UserControlPages { MessageBox.Show($"编号为{s}的物料删除失败", "提示"); } + SqlLogHelper.AddLog($"物料信息删除成功 物料编号[{s}]"); Lists = zxMaterialService.GetMaterialInfos(); MaterialDataGridView.DataSource = null; diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.cs index d595cc5..48ab303 100644 --- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.cs +++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialTypeConfigPage.cs @@ -1,4 +1,5 @@ using HighWayIot.Repository.service; +using HighWayIot.Winform.Business; using Models; using System; using System.Collections.Generic; @@ -80,6 +81,8 @@ namespace HighWayIot.Winform.UserControlPages.MaterialConfigPages MaterialTypeName = material, }); + SqlLogHelper.AddLog($"物料类型信息添加成功 名称:[{material}]"); + zxMaterialTypeList = zxMaterialTypeService.GetMaterialTypeInfos(); MaterialTypeDataGridView.DataSource = null; @@ -117,6 +120,7 @@ namespace HighWayIot.Winform.UserControlPages.MaterialConfigPages MaterialTypeName = s, MaterialChlidTypeName = material, }); + SqlLogHelper.AddLog($"物料子类型添加成功 名称:[{material}]"); zxMaterialChildTypeList = zxMaterialChildTypeService.GetMaterialChildTypeInfos(x => x.MaterialTypeName == s); @@ -150,6 +154,7 @@ namespace HighWayIot.Winform.UserControlPages.MaterialConfigPages { MessageBox.Show("关联子物料类型删除失败!", "提示"); } + SqlLogHelper.AddLog($"物料类型关联的子类型删除成功 名称:[{s}]"); } } @@ -158,6 +163,7 @@ namespace HighWayIot.Winform.UserControlPages.MaterialConfigPages if (zxMaterialTypeService.DeleteMaterialTypeInfoById(id)) { MessageBox.Show("删除成功!", "提示"); + SqlLogHelper.AddLog($"物料类型删除成功 名称:[{s}]"); } zxMaterialTypeList = zxMaterialTypeService.GetMaterialTypeInfos(); @@ -186,6 +192,7 @@ namespace HighWayIot.Winform.UserControlPages.MaterialConfigPages if (zxMaterialChildTypeService.DeleteMaterialChildTypeInfoById(id)) { MessageBox.Show("删除成功!", "提示"); + SqlLogHelper.AddLog($"物料子类型删除成功 名称:[{MaterialChildTypeDataGridView.Rows[a].Cells["MaterialChildTypeName"].Value.ToString()}]"); } //获取选择的物料类型行 diff --git a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialUpdateForm.cs b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialUpdateForm.cs index f4a6a2c..a1b398b 100644 --- a/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialUpdateForm.cs +++ b/HighWayIot.Winform/UserControlPages/MaterialConfigPages/MaterialUpdateForm.cs @@ -119,6 +119,7 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages if (zxMaterialService.UpdateMaterialInfo(entity)) { MessageBox.Show("物料信息修改成功!", "提示"); + SqlLogHelper.AddLog($"物料信息修改成功 物料编号[{entity.MaterialCode}]"); } else { @@ -126,7 +127,6 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages return; } - this.Close(); this.Dispose(); } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.cs index 66f724f..9cea563 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/EquipParamSettingPage.cs @@ -1,5 +1,6 @@ using HighWayIot.Repository.domain; using HighWayIot.Repository.service; +using HighWayIot.Winform.Business; using Models; using System; using System.Collections.Generic; @@ -94,6 +95,7 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages if (zxOpenMixMaterialService.UpDateInfos(list)) { MessageBox.Show("开炼机物料配置信息保存成功"); + SqlLogHelper.AddLog($"开炼机物料配置信息保存成功 1:[{OpenMixMaterial1.Text}]|2:[{OpenMixMaterial2.Text}]|3:[{OpenMixMaterial3.Text}]|4:[{OpenMixMaterial4.Text}]|5:[{OpenMixMaterial5.Text}]"); } else { diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.Designer.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.Designer.cs index ce48641..4f927e7 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.Designer.cs @@ -43,10 +43,10 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages this.UpdateConfigButton = new System.Windows.Forms.Button(); this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.DeviceNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RecipeCode1 = new System.Windows.Forms.DataGridViewComboBoxColumn(); - this.RecipeName1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RecipeCode2 = new System.Windows.Forms.DataGridViewComboBoxColumn(); - this.RecipeName2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RecipeCode2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RecipeName2 = new System.Windows.Forms.DataGridViewComboBoxColumn(); + this.RecipeCode1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RecipeName1 = new System.Windows.Forms.DataGridViewComboBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.SchedulingDataGridView)).BeginInit(); this.ButtonPanel.SuspendLayout(); this.SuspendLayout(); @@ -60,10 +60,10 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages this.SchedulingDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Id, this.DeviceNo, - this.RecipeCode1, - this.RecipeName1, this.RecipeCode2, - this.RecipeName2}); + this.RecipeName2, + this.RecipeCode1, + this.RecipeName1}); this.SchedulingDataGridView.Location = new System.Drawing.Point(0, 65); this.SchedulingDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.SchedulingDataGridView.Name = "SchedulingDataGridView"; @@ -82,7 +82,7 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages this.SelectConfigButton.Name = "SelectConfigButton"; this.SelectConfigButton.Size = new System.Drawing.Size(103, 39); this.SelectConfigButton.TabIndex = 1; - this.SelectConfigButton.Text = "查询配置信息"; + this.SelectConfigButton.Text = "刷新配置信息"; this.SelectConfigButton.UseVisualStyleBackColor = true; this.SelectConfigButton.Click += new System.EventHandler(this.SelectConfigButton_Click); // @@ -105,7 +105,7 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages this.UpdateConfigButton.Name = "UpdateConfigButton"; this.UpdateConfigButton.Size = new System.Drawing.Size(103, 39); this.UpdateConfigButton.TabIndex = 2; - this.UpdateConfigButton.Text = "修改配置信息"; + this.UpdateConfigButton.Text = "保存配置信息"; this.UpdateConfigButton.UseVisualStyleBackColor = true; this.UpdateConfigButton.Click += new System.EventHandler(this.UpdateConfigButton_Click); // @@ -130,51 +130,54 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages this.DeviceNo.ReadOnly = true; this.DeviceNo.Resizable = System.Windows.Forms.DataGridViewTriState.False; // - // RecipeCode1 - // - this.RecipeCode1.DataPropertyName = "RecipeCode1"; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.Transparent; - dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle3.ForeColor = System.Drawing.Color.Black; - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Transparent; - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.Black; - this.RecipeCode1.DefaultCellStyle = dataGridViewCellStyle3; - this.RecipeCode1.HeaderText = "成品代号 - 上模"; - this.RecipeCode1.Name = "RecipeCode1"; - this.RecipeCode1.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.RecipeCode1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; - this.RecipeCode1.Width = 200; - // - // RecipeName1 - // - this.RecipeName1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.RecipeName1.DataPropertyName = "RecipeName1"; - dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.RecipeName1.DefaultCellStyle = dataGridViewCellStyle4; - this.RecipeName1.HeaderText = "标称尺度 - 上模"; - this.RecipeName1.Name = "RecipeName1"; - this.RecipeName1.Resizable = System.Windows.Forms.DataGridViewTriState.False; - // // RecipeCode2 // this.RecipeCode2.DataPropertyName = "RecipeCode2"; - dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.RecipeCode2.DefaultCellStyle = dataGridViewCellStyle5; - this.RecipeCode2.HeaderText = "成品代号 - 下模"; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.RecipeCode2.DefaultCellStyle = dataGridViewCellStyle3; + this.RecipeCode2.HeaderText = "成品代号 - 上模"; this.RecipeCode2.Name = "RecipeCode2"; + this.RecipeCode2.ReadOnly = true; this.RecipeCode2.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.RecipeCode2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; this.RecipeCode2.Width = 200; // // RecipeName2 // this.RecipeName2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.RecipeName2.DataPropertyName = "RecipeName2"; - dataGridViewCellStyle6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.RecipeName2.DefaultCellStyle = dataGridViewCellStyle6; - this.RecipeName2.HeaderText = "标称尺度 - 下模"; + dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.RecipeName2.DefaultCellStyle = dataGridViewCellStyle4; + this.RecipeName2.HeaderText = "标称尺度 - 上模"; this.RecipeName2.Name = "RecipeName2"; this.RecipeName2.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.RecipeName2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // RecipeCode1 + // + this.RecipeCode1.DataPropertyName = "RecipeCode1"; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.White; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.Black; + this.RecipeCode1.DefaultCellStyle = dataGridViewCellStyle5; + this.RecipeCode1.HeaderText = "成品代号 - 下模"; + this.RecipeCode1.Name = "RecipeCode1"; + this.RecipeCode1.ReadOnly = true; + this.RecipeCode1.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.RecipeCode1.Width = 200; + // + // RecipeName1 + // + this.RecipeName1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.RecipeName1.DataPropertyName = "RecipeName1"; + dataGridViewCellStyle6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.RecipeName1.DefaultCellStyle = dataGridViewCellStyle6; + this.RecipeName1.HeaderText = "标称尺度 - 下模"; + this.RecipeName1.Name = "RecipeName1"; + this.RecipeName1.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.RecipeName1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; // // ProductionScheduling // @@ -200,9 +203,9 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages private Button UpdateConfigButton; private DataGridViewTextBoxColumn Id; private DataGridViewTextBoxColumn DeviceNo; - private DataGridViewComboBoxColumn RecipeCode1; - private DataGridViewTextBoxColumn RecipeName1; - private DataGridViewComboBoxColumn RecipeCode2; - private DataGridViewTextBoxColumn RecipeName2; + private DataGridViewTextBoxColumn RecipeCode2; + private DataGridViewComboBoxColumn RecipeName2; + private DataGridViewTextBoxColumn RecipeCode1; + private DataGridViewComboBoxColumn RecipeName1; } } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.cs index 2d465c0..91be6e3 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.cs @@ -1,5 +1,6 @@ using HighWayIot.Log4net; using HighWayIot.Repository.service; +using HighWayIot.Winform.Business; using Models; using System; using System.Collections.Generic; @@ -60,17 +61,24 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages private void ComboBoxBind() { zxRecipeEntities = zxRecipeService.GetRecipeInfos(); - RecipeCode1.DataSource = null; - RecipeCode1.DataSource = null; + RecipeName1.DataSource = null; + RecipeName2.DataSource = null; - List r1 = zxRecipeEntities.Select(x => x.RecipeCode).ToList(); + List r1 = zxRecipeEntities.Select(x => x.RecipeName).ToList(); + r1.Sort(); r1.Insert(0, ""); - RecipeCode1.DataSource = r1; - List r2 = zxRecipeEntities.Select(x => x.RecipeCode).ToList(); + RecipeName1.DataSource = r1; + List r2 = zxRecipeEntities.Select(x => x.RecipeName).ToList(); + r2.Sort(); r2.Insert(0, ""); - RecipeCode2.DataSource = r2; + RecipeName2.DataSource = r2; } + /// + /// 更新设置 + /// + /// + /// private void UpdateConfigButton_Click(object sender, EventArgs e) { if (zxSchedulingService.UpdateSchedulingInfo(zxSchedulingEntity)) @@ -114,10 +122,12 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages ComboBox cbo = new ComboBox(); private void SchedulingDataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { - if (SchedulingDataGridView.CurrentCell.OwningColumn.Name.Contains("RecipeCode") && SchedulingDataGridView.CurrentCell.RowIndex != -1) + if (SchedulingDataGridView.CurrentCell.OwningColumn.Name.Contains("RecipeName") && SchedulingDataGridView.CurrentCell.RowIndex != -1) { //保存当前的事件源。为了触发事件后。在取消 cbo = e.Control as ComboBox; + //cbo.AutoCompleteSource = AutoCompleteSource.CustomSource; + //cbo.AutoCompleteMode = AutoCompleteMode.SuggestAppend; cbo.SelectedIndexChanged += new EventHandler(cbo_SelectedIndexChanged); } } @@ -137,30 +147,35 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages { int row = SchedulingDataGridView.CurrentCell.RowIndex; int column = SchedulingDataGridView.CurrentCell.ColumnIndex; + string DeviceNo = SchedulingDataGridView.Rows[row].Cells[1].Value.ToString(); - if(column == 2) + if(column == 5) { - ZxRecipeEntity recipe = zxRecipeService.GetSingleInfoByRecipeCode(combox.Text); + ZxRecipeEntity recipe = zxRecipeService.GetSingleInfoByRecipeName(combox.Text); if (recipe == null) { - zxSchedulingEntity[row].RecipeName1 = string.Empty; + MessageBox.Show("存在多个相同的标称尺度或不存在,请检查并维护配方,重启排程界面"); + zxSchedulingEntity[row].RecipeCode1 = string.Empty; } else { - zxSchedulingEntity[row].RecipeName1 = recipe.RecipeName; + zxSchedulingEntity[row].RecipeCode1 = recipe.RecipeCode; + SqlLogHelper.AddLog($"排程信息操作 机台[{DeviceNo}下模] 配方更改为[{recipe.RecipeCode}]"); } } - if(column == 4) + if (column == 3) { - ZxRecipeEntity recipe = zxRecipeService.GetSingleInfoByRecipeCode(combox.Text); + ZxRecipeEntity recipe = zxRecipeService.GetSingleInfoByRecipeName(combox.Text); if (recipe == null) { - zxSchedulingEntity[row].RecipeName2 = string.Empty; + MessageBox.Show("存在多个相同的标称尺度或不存在,请检查并维护配方,重启排程界面"); + zxSchedulingEntity[row].RecipeCode2 = string.Empty; } else { - zxSchedulingEntity[row].RecipeName2 = recipe.RecipeName; + zxSchedulingEntity[row].RecipeCode2 = recipe.RecipeCode; + SqlLogHelper.AddLog($"排程信息操作 机台[{DeviceNo}上模] 配方更改为[{recipe.RecipeCode}]"); } } SchedulingDataGridView.Refresh(); @@ -181,5 +196,7 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages //做完处理,须撤销动态事件 combox.SelectedIndexChanged -= new EventHandler(cbo_SelectedIndexChanged); } + } + } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.resx b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.resx index c19eaa6..3f49bb9 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.resx +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/ProductionScheduling.resx @@ -123,16 +123,16 @@ True - - True - - - True - True True + + True + + + True + \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.Designer.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.Designer.cs index 8ba8a2f..fb56267 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.Designer.cs @@ -37,9 +37,6 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages this.ButtonPanel = new System.Windows.Forms.Panel(); this.UpdateReaderButton = new System.Windows.Forms.Button(); this.ReaderDataGridView = new System.Windows.Forms.DataGridView(); - this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RfidIp = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.WorkstationNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.RFIDSettingGroupBox = new System.Windows.Forms.GroupBox(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.panel1 = new System.Windows.Forms.Panel(); @@ -48,6 +45,9 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.TagDataGridView = new System.Windows.Forms.DataGridView(); + this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RfidIp = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.WorkstationNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.RfidId = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.RfidEpc = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.DeviceNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -119,29 +119,6 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages this.ReaderDataGridView.Size = new System.Drawing.Size(688, 842); this.ReaderDataGridView.TabIndex = 5; // - // Id - // - this.Id.DataPropertyName = "Id"; - this.Id.HeaderText = "编号"; - this.Id.Name = "Id"; - this.Id.Width = 40; - // - // RfidIp - // - this.RfidIp.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.RfidIp.DataPropertyName = "RfidIp"; - this.RfidIp.FillWeight = 5F; - this.RfidIp.HeaderText = "设备ip"; - this.RfidIp.Name = "RfidIp"; - // - // WorkstationNo - // - this.WorkstationNo.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.WorkstationNo.DataPropertyName = "WorkstationNo"; - this.WorkstationNo.FillWeight = 5F; - this.WorkstationNo.HeaderText = "工位编号"; - this.WorkstationNo.Name = "WorkstationNo"; - // // RFIDSettingGroupBox // this.RFIDSettingGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -259,11 +236,36 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages this.TagDataGridView.Size = new System.Drawing.Size(689, 842); this.TagDataGridView.TabIndex = 5; // + // Id + // + this.Id.DataPropertyName = "Id"; + this.Id.HeaderText = "编号"; + this.Id.Name = "Id"; + this.Id.ReadOnly = true; + this.Id.Width = 40; + // + // RfidIp + // + this.RfidIp.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.RfidIp.DataPropertyName = "RfidIp"; + this.RfidIp.FillWeight = 5F; + this.RfidIp.HeaderText = "设备ip"; + this.RfidIp.Name = "RfidIp"; + // + // WorkstationNo + // + this.WorkstationNo.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.WorkstationNo.DataPropertyName = "WorkstationNo"; + this.WorkstationNo.FillWeight = 5F; + this.WorkstationNo.HeaderText = "工位编号"; + this.WorkstationNo.Name = "WorkstationNo"; + // // RfidId // this.RfidId.DataPropertyName = "Id"; this.RfidId.HeaderText = "编号"; this.RfidId.Name = "RfidId"; + this.RfidId.ReadOnly = true; this.RfidId.Width = 40; // // RfidEpc @@ -315,13 +317,13 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages private Button SelectRfidButton; private GroupBox groupBox1; private DataGridView TagDataGridView; + private Button UpdateReaderButton; + private Button UpdateRFIDButton; private DataGridViewTextBoxColumn Id; private DataGridViewTextBoxColumn RfidIp; private DataGridViewTextBoxColumn WorkstationNo; private DataGridViewTextBoxColumn RfidId; private DataGridViewTextBoxColumn RfidEpc; private DataGridViewTextBoxColumn DeviceNo; - private Button UpdateReaderButton; - private Button UpdateRFIDButton; } } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.cs index 38ca66f..d8316b1 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.cs @@ -1,5 +1,6 @@ using HighWayIot.Repository.domain; using HighWayIot.Repository.service; +using HighWayIot.Winform.Business; using System; using System.Collections.Generic; using System.ComponentModel; @@ -94,6 +95,7 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages RefreshReaderGridView(); MessageBox.Show("读写器信息修改成功"); + SqlLogHelper.AddLog($"读写器信息修改成功"); } /// @@ -121,6 +123,7 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages RefreshReaderGridView(); MessageBox.Show("标签信息修改成功"); + SqlLogHelper.AddLog($"标签信息修改成功"); } } } diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddRecipeForm.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddRecipeForm.cs index a7f60dd..d06eba1 100644 --- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddRecipeForm.cs +++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddRecipeForm.cs @@ -1,4 +1,5 @@ using HighWayIot.Repository.service; +using HighWayIot.Winform.Business; using Models; using System; using System.Collections.Generic; @@ -80,6 +81,7 @@ namespace HighWayIot.Winform.UserControlPages.RecipeConfigPages if(zxRecipeService.InsertRecipeInfo(zxRecipeEntity)) { MessageBox.Show("配方信息添加成功"); + SqlLogHelper.AddLog($"配方信息添加成功 {zxRecipeEntity.RecipeSpecName}"); this.CloseValue = zxRecipeEntity; this.Close(); this.Dispose(); diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.Designer.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.Designer.cs index e90f7b7..a9cfa80 100644 --- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.Designer.cs @@ -57,6 +57,10 @@ this.label12 = new System.Windows.Forms.Label(); this.SetWidthTextBox2 = new System.Windows.Forms.TextBox(); this.label13 = new System.Windows.Forms.Label(); + this.SetLayerTextBox3 = new System.Windows.Forms.TextBox(); + this.label14 = new System.Windows.Forms.Label(); + this.SetWidthTextBox3 = new System.Windows.Forms.TextBox(); + this.label15 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // @@ -324,11 +328,47 @@ this.label13.TabIndex = 25; this.label13.Text = "宽度2:"; // + // SetLayerTextBox3 + // + this.SetLayerTextBox3.Location = new System.Drawing.Point(450, 199); + this.SetLayerTextBox3.Name = "SetLayerTextBox3"; + this.SetLayerTextBox3.Size = new System.Drawing.Size(123, 21); + this.SetLayerTextBox3.TabIndex = 32; + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(403, 203); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(47, 12); + this.label14.TabIndex = 31; + this.label14.Text = "层数3:"; + // + // SetWidthTextBox3 + // + this.SetWidthTextBox3.Location = new System.Drawing.Point(272, 199); + this.SetWidthTextBox3.Name = "SetWidthTextBox3"; + this.SetWidthTextBox3.Size = new System.Drawing.Size(123, 21); + this.SetWidthTextBox3.TabIndex = 30; + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(225, 203); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(47, 12); + this.label15.TabIndex = 29; + this.label15.Text = "宽度3:"; + // // AddWeightForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(638, 294); + this.Controls.Add(this.SetLayerTextBox3); + this.Controls.Add(this.label14); + this.Controls.Add(this.SetWidthTextBox3); + this.Controls.Add(this.label15); this.Controls.Add(this.SetLayerTextBox2); this.Controls.Add(this.label12); this.Controls.Add(this.SetWidthTextBox2); @@ -392,5 +432,9 @@ private System.Windows.Forms.Label label12; private System.Windows.Forms.TextBox SetWidthTextBox2; private System.Windows.Forms.Label label13; + private System.Windows.Forms.TextBox SetLayerTextBox3; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.TextBox SetWidthTextBox3; + private System.Windows.Forms.Label label15; } } \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.cs index 875c2c5..9539573 100644 --- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.cs +++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/AddWeightForm.cs @@ -153,6 +153,13 @@ namespace HighWayIot.Winform.UserControlPages.RecipeConfigPages } zxWeightEntity.SetWidth2 = width2; + if (!decimal.TryParse(SetWidthTextBox3.Text.Trim(), out decimal width3) && !string.IsNullOrEmpty(SetWidthTextBox2.Text.Trim())) + { + MessageBox.Show("宽度请填入可带小数的阿拉伯数字"); + return; + } + zxWeightEntity.SetWidth3 = width3; + if (!int.TryParse(SetLayerTextBox.Text.Trim(), out int layer) && !string.IsNullOrEmpty(SetLayerTextBox.Text.Trim())) { MessageBox.Show("层数请填入整数阿拉伯数字"); @@ -167,6 +174,13 @@ namespace HighWayIot.Winform.UserControlPages.RecipeConfigPages } zxWeightEntity.SetLayer2 = layer2; + if (!int.TryParse(SetLayerTextBox3.Text.Trim(), out int layer3) && !string.IsNullOrEmpty(SetLayerTextBox2.Text.Trim())) + { + MessageBox.Show("层数请填入整数阿拉伯数字"); + return; + } + zxWeightEntity.SetLayer3 = layer3; + if (!decimal.TryParse(SetWeightTextBox.Text.Trim(), out decimal weight) && !string.IsNullOrEmpty(SetWeightTextBox.Text.Trim())) { MessageBox.Show("重量请填入可带小数的阿拉伯数字"); @@ -184,6 +198,7 @@ namespace HighWayIot.Winform.UserControlPages.RecipeConfigPages if (zxWeightService.InsertWeightInfo(zxWeightEntity)) { MessageBox.Show("成型信息添加成功!"); + SqlLogHelper.AddLog($"成型信息添加成功 {zxWeightEntity.RecipeCode}"); } else { diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs index b77336e..1f319ae 100644 --- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.Designer.cs @@ -32,18 +32,6 @@ namespace HighWayIot.Winform.UserControlPages private void InitializeComponent() { this.WeightDataGridView = new System.Windows.Forms.DataGridView(); - this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.MaterialCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.MaterialName = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.MaterialType = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.SetThickness = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.SetWidth1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.SetLayer1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.SetWidth2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.SetLayer2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.SetWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.SetError = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.WeightIsUse = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.AddRecipeButton = new System.Windows.Forms.Button(); this.ButtonPanel = new System.Windows.Forms.Panel(); this.SyncDataButton = new System.Windows.Forms.Button(); @@ -82,6 +70,16 @@ namespace HighWayIot.Winform.UserControlPages this.DownloadFromPlc = new System.Windows.Forms.Button(); this.UpLoadToPlc = new System.Windows.Forms.Button(); this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.label20 = new System.Windows.Forms.Label(); + this.E15TextBox = new System.Windows.Forms.TextBox(); + this.label24 = new System.Windows.Forms.Label(); + this.E14TextBox = new System.Windows.Forms.TextBox(); + this.label25 = new System.Windows.Forms.Label(); + this.E13TextBox = new System.Windows.Forms.TextBox(); + this.label33 = new System.Windows.Forms.Label(); + this.E12TextBox = new System.Windows.Forms.TextBox(); + this.label35 = new System.Windows.Forms.Label(); + this.E11TextBox = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); this.E10TextBox = new System.Windows.Forms.TextBox(); this.label7 = new System.Windows.Forms.Label(); @@ -154,6 +152,20 @@ namespace HighWayIot.Winform.UserControlPages this.UpdateWeightButton = new System.Windows.Forms.Button(); this.AddWeightButton = new System.Windows.Forms.Button(); this.DeleteWeightButton = new System.Windows.Forms.Button(); + this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MaterialCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MaterialName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MaterialType = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SetThickness = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SetWidth1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SetLayer1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SetWidth2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SetLayer2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SetWidth3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SetLayer3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SetWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SetError = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.WeightIsUse = new System.Windows.Forms.DataGridViewCheckBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.WeightDataGridView)).BeginInit(); this.ButtonPanel.SuspendLayout(); this.groupBox1.SuspendLayout(); @@ -187,6 +199,8 @@ namespace HighWayIot.Winform.UserControlPages this.SetLayer1, this.SetWidth2, this.SetLayer2, + this.SetWidth3, + this.SetLayer3, this.SetWeight, this.SetError, this.WeightIsUse}); @@ -196,111 +210,10 @@ namespace HighWayIot.Winform.UserControlPages this.WeightDataGridView.Name = "WeightDataGridView"; this.WeightDataGridView.RowHeadersVisible = false; this.WeightDataGridView.RowTemplate.Height = 25; - this.WeightDataGridView.Size = new System.Drawing.Size(855, 793); + this.WeightDataGridView.Size = new System.Drawing.Size(947, 722); this.WeightDataGridView.TabIndex = 0; this.WeightDataGridView.Tag = ""; // - // Id - // - this.Id.DataPropertyName = "Id"; - this.Id.HeaderText = "ID"; - this.Id.Name = "Id"; - this.Id.ReadOnly = true; - this.Id.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.Id.Width = 40; - // - // MaterialCode - // - this.MaterialCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.MaterialCode.DataPropertyName = "MaterialCode"; - this.MaterialCode.HeaderText = "胶料编码"; - this.MaterialCode.Name = "MaterialCode"; - this.MaterialCode.ReadOnly = true; - this.MaterialCode.Resizable = System.Windows.Forms.DataGridViewTriState.False; - // - // MaterialName - // - this.MaterialName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.MaterialName.DataPropertyName = "MaterialName"; - this.MaterialName.HeaderText = "胶料名称"; - this.MaterialName.Name = "MaterialName"; - this.MaterialName.ReadOnly = true; - this.MaterialName.Resizable = System.Windows.Forms.DataGridViewTriState.False; - // - // MaterialType - // - this.MaterialType.DataPropertyName = "MaterialType"; - this.MaterialType.HeaderText = "胶料类型"; - this.MaterialType.Name = "MaterialType"; - this.MaterialType.ReadOnly = true; - this.MaterialType.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.MaterialType.Width = 89; - // - // SetThickness - // - this.SetThickness.DataPropertyName = "SetThickness"; - this.SetThickness.HeaderText = "厚度"; - this.SetThickness.Name = "SetThickness"; - this.SetThickness.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.SetThickness.Width = 59; - // - // SetWidth1 - // - this.SetWidth1.DataPropertyName = "SetWidth"; - this.SetWidth1.HeaderText = "宽度1"; - this.SetWidth1.Name = "SetWidth1"; - this.SetWidth1.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.SetWidth1.Width = 60; - // - // SetLayer1 - // - this.SetLayer1.DataPropertyName = "SetLayer"; - this.SetLayer1.HeaderText = "层数1"; - this.SetLayer1.Name = "SetLayer1"; - this.SetLayer1.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.SetLayer1.Width = 60; - // - // SetWidth2 - // - this.SetWidth2.DataPropertyName = "SetWidth2"; - this.SetWidth2.HeaderText = "宽度2"; - this.SetWidth2.Name = "SetWidth2"; - this.SetWidth2.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.SetWidth2.Width = 60; - // - // SetLayer2 - // - this.SetLayer2.DataPropertyName = "SetLayer2"; - this.SetLayer2.HeaderText = "层数2"; - this.SetLayer2.Name = "SetLayer2"; - this.SetLayer2.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.SetLayer2.Width = 60; - // - // SetWeight - // - this.SetWeight.DataPropertyName = "SetWeight"; - this.SetWeight.HeaderText = "重量"; - this.SetWeight.Name = "SetWeight"; - this.SetWeight.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.SetWeight.Width = 70; - // - // SetError - // - this.SetError.DataPropertyName = "SetError"; - this.SetError.HeaderText = "公差"; - this.SetError.Name = "SetError"; - this.SetError.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.SetError.Width = 55; - // - // WeightIsUse - // - this.WeightIsUse.DataPropertyName = "IsUse"; - this.WeightIsUse.HeaderText = "启用"; - this.WeightIsUse.Name = "WeightIsUse"; - this.WeightIsUse.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.WeightIsUse.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; - this.WeightIsUse.Width = 40; - // // AddRecipeButton // this.AddRecipeButton.Location = new System.Drawing.Point(11, 12); @@ -325,13 +238,13 @@ namespace HighWayIot.Winform.UserControlPages this.ButtonPanel.Location = new System.Drawing.Point(0, 0); this.ButtonPanel.Margin = new System.Windows.Forms.Padding(0); this.ButtonPanel.Name = "ButtonPanel"; - this.ButtonPanel.Size = new System.Drawing.Size(861, 63); + this.ButtonPanel.Size = new System.Drawing.Size(952, 63); this.ButtonPanel.TabIndex = 4; // // SyncDataButton // this.SyncDataButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.SyncDataButton.Location = new System.Drawing.Point(637, 12); + this.SyncDataButton.Location = new System.Drawing.Point(728, 12); this.SyncDataButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.SyncDataButton.Name = "SyncDataButton"; this.SyncDataButton.Size = new System.Drawing.Size(103, 39); @@ -374,7 +287,7 @@ namespace HighWayIot.Winform.UserControlPages // DeleteRecipeButton // this.DeleteRecipeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.DeleteRecipeButton.Location = new System.Drawing.Point(746, 12); + this.DeleteRecipeButton.Location = new System.Drawing.Point(837, 12); this.DeleteRecipeButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.DeleteRecipeButton.Name = "DeleteRecipeButton"; this.DeleteRecipeButton.Size = new System.Drawing.Size(103, 39); @@ -387,10 +300,10 @@ namespace HighWayIot.Winform.UserControlPages // this.groupBox1.Controls.Add(this.WeightDataGridView); this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(861, 0); + this.groupBox1.Location = new System.Drawing.Point(952, 0); this.groupBox1.Margin = new System.Windows.Forms.Padding(0); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(861, 813); + this.groupBox1.Size = new System.Drawing.Size(953, 742); this.groupBox1.TabIndex = 5; this.groupBox1.TabStop = false; this.groupBox1.Text = "成型信息"; @@ -402,7 +315,7 @@ namespace HighWayIot.Winform.UserControlPages this.groupBox2.Location = new System.Drawing.Point(0, 0); this.groupBox2.Margin = new System.Windows.Forms.Padding(0); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(861, 813); + this.groupBox2.Size = new System.Drawing.Size(952, 742); this.groupBox2.TabIndex = 6; this.groupBox2.TabStop = false; this.groupBox2.Text = "配方列表"; @@ -411,7 +324,6 @@ namespace HighWayIot.Winform.UserControlPages // this.RecipeDataGridView.AllowUserToAddRows = false; this.RecipeDataGridView.AllowUserToDeleteRows = false; - this.RecipeDataGridView.AllowUserToResizeColumns = false; this.RecipeDataGridView.AllowUserToResizeRows = false; this.RecipeDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.RecipeDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { @@ -428,9 +340,8 @@ namespace HighWayIot.Winform.UserControlPages this.RecipeDataGridView.Location = new System.Drawing.Point(3, 17); this.RecipeDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.RecipeDataGridView.Name = "RecipeDataGridView"; - this.RecipeDataGridView.RowHeadersVisible = false; this.RecipeDataGridView.RowTemplate.Height = 25; - this.RecipeDataGridView.Size = new System.Drawing.Size(855, 793); + this.RecipeDataGridView.Size = new System.Drawing.Size(946, 722); this.RecipeDataGridView.TabIndex = 0; this.RecipeDataGridView.Tag = ""; this.RecipeDataGridView.SelectionChanged += new System.EventHandler(this.RecipeDataGridView_SelectionChanged); @@ -471,6 +382,7 @@ namespace HighWayIot.Winform.UserControlPages this.RecipeSpecCode.Name = "RecipeSpecCode"; this.RecipeSpecCode.ReadOnly = true; this.RecipeSpecCode.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.RecipeSpecCode.Width = 90; // // RecipeSpecName // @@ -532,7 +444,7 @@ namespace HighWayIot.Winform.UserControlPages this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 1; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(1722, 813); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1905, 742); this.tableLayoutPanel1.TabIndex = 7; // // groupBox3 @@ -543,7 +455,7 @@ namespace HighWayIot.Winform.UserControlPages this.groupBox3.Location = new System.Drawing.Point(0, 0); this.groupBox3.Margin = new System.Windows.Forms.Padding(0); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(1722, 190); + this.groupBox3.Size = new System.Drawing.Size(1905, 190); this.groupBox3.TabIndex = 8; this.groupBox3.TabStop = false; this.groupBox3.Text = "配方参数"; @@ -562,7 +474,7 @@ namespace HighWayIot.Winform.UserControlPages this.tableLayoutPanel3.Name = "tableLayoutPanel3"; this.tableLayoutPanel3.RowCount = 1; this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel3.Size = new System.Drawing.Size(1716, 170); + this.tableLayoutPanel3.Size = new System.Drawing.Size(1899, 170); this.tableLayoutPanel3.TabIndex = 0; // // groupBox7 @@ -738,6 +650,16 @@ namespace HighWayIot.Winform.UserControlPages // // groupBox4 // + this.groupBox4.Controls.Add(this.label20); + this.groupBox4.Controls.Add(this.E15TextBox); + this.groupBox4.Controls.Add(this.label24); + this.groupBox4.Controls.Add(this.E14TextBox); + this.groupBox4.Controls.Add(this.label25); + this.groupBox4.Controls.Add(this.E13TextBox); + this.groupBox4.Controls.Add(this.label33); + this.groupBox4.Controls.Add(this.E12TextBox); + this.groupBox4.Controls.Add(this.label35); + this.groupBox4.Controls.Add(this.E11TextBox); this.groupBox4.Controls.Add(this.label6); this.groupBox4.Controls.Add(this.E10TextBox); this.groupBox4.Controls.Add(this.label7); @@ -763,31 +685,111 @@ namespace HighWayIot.Winform.UserControlPages this.groupBox4.Location = new System.Drawing.Point(400, 0); this.groupBox4.Margin = new System.Windows.Forms.Padding(0); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(658, 170); + this.groupBox4.Size = new System.Drawing.Size(749, 170); this.groupBox4.TabIndex = 4; this.groupBox4.TabStop = false; this.groupBox4.Text = "贴合参数"; // + // label20 + // + this.label20.AutoSize = true; + this.label20.Location = new System.Drawing.Point(591, 139); + this.label20.Name = "label20"; + this.label20.Size = new System.Drawing.Size(17, 12); + this.label20.TabIndex = 38; + this.label20.Text = "15"; + // + // E15TextBox + // + this.E15TextBox.Location = new System.Drawing.Point(621, 136); + this.E15TextBox.Name = "E15TextBox"; + this.E15TextBox.Size = new System.Drawing.Size(80, 21); + this.E15TextBox.TabIndex = 37; + // + // label24 + // + this.label24.AutoSize = true; + this.label24.Location = new System.Drawing.Point(591, 112); + this.label24.Name = "label24"; + this.label24.Size = new System.Drawing.Size(17, 12); + this.label24.TabIndex = 36; + this.label24.Text = "14"; + // + // E14TextBox + // + this.E14TextBox.Location = new System.Drawing.Point(621, 109); + this.E14TextBox.Name = "E14TextBox"; + this.E14TextBox.Size = new System.Drawing.Size(80, 21); + this.E14TextBox.TabIndex = 35; + // + // label25 + // + this.label25.AutoSize = true; + this.label25.Location = new System.Drawing.Point(591, 85); + this.label25.Name = "label25"; + this.label25.Size = new System.Drawing.Size(17, 12); + this.label25.TabIndex = 34; + this.label25.Text = "13"; + // + // E13TextBox + // + this.E13TextBox.Location = new System.Drawing.Point(621, 82); + this.E13TextBox.Name = "E13TextBox"; + this.E13TextBox.Size = new System.Drawing.Size(80, 21); + this.E13TextBox.TabIndex = 33; + // + // label33 + // + this.label33.AutoSize = true; + this.label33.Location = new System.Drawing.Point(591, 59); + this.label33.Name = "label33"; + this.label33.Size = new System.Drawing.Size(17, 12); + this.label33.TabIndex = 32; + this.label33.Text = "12"; + // + // E12TextBox + // + this.E12TextBox.Location = new System.Drawing.Point(621, 55); + this.E12TextBox.Name = "E12TextBox"; + this.E12TextBox.Size = new System.Drawing.Size(80, 21); + this.E12TextBox.TabIndex = 31; + // + // label35 + // + this.label35.AutoSize = true; + this.label35.Location = new System.Drawing.Point(591, 31); + this.label35.Name = "label35"; + this.label35.Size = new System.Drawing.Size(17, 12); + this.label35.TabIndex = 30; + this.label35.Text = "11"; + // + // E11TextBox + // + this.E11TextBox.Location = new System.Drawing.Point(621, 28); + this.E11TextBox.Name = "E11TextBox"; + this.E11TextBox.Size = new System.Drawing.Size(80, 21); + this.E11TextBox.TabIndex = 29; + // // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(377, 141); + this.label6.Location = new System.Drawing.Point(375, 139); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(95, 12); + this.label6.Size = new System.Drawing.Size(53, 12); this.label6.TabIndex = 28; - this.label6.Text = "贴合补偿脉冲(P)"; + this.label6.Text = "停止距离"; // // E10TextBox // - this.E10TextBox.Location = new System.Drawing.Point(478, 137); + this.E10TextBox.Location = new System.Drawing.Point(434, 136); this.E10TextBox.Name = "E10TextBox"; - this.E10TextBox.Size = new System.Drawing.Size(100, 21); + this.E10TextBox.Size = new System.Drawing.Size(80, 21); this.E10TextBox.TabIndex = 27; // // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(377, 114); + this.label7.Location = new System.Drawing.Point(333, 113); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(95, 12); this.label7.TabIndex = 26; @@ -795,31 +797,31 @@ namespace HighWayIot.Winform.UserControlPages // // E9TextBox // - this.E9TextBox.Location = new System.Drawing.Point(478, 110); + this.E9TextBox.Location = new System.Drawing.Point(434, 109); this.E9TextBox.Name = "E9TextBox"; - this.E9TextBox.Size = new System.Drawing.Size(100, 21); + this.E9TextBox.Size = new System.Drawing.Size(80, 21); this.E9TextBox.TabIndex = 25; // // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(353, 87); + this.label8.Location = new System.Drawing.Point(393, 86); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(119, 12); + this.label8.Size = new System.Drawing.Size(35, 12); this.label8.TabIndex = 24; - this.label8.Text = "包边宽度(3/4/5工位)"; + this.label8.Text = "备用3"; // // E8TextBox // - this.E8TextBox.Location = new System.Drawing.Point(478, 83); + this.E8TextBox.Location = new System.Drawing.Point(434, 82); this.E8TextBox.Name = "E8TextBox"; - this.E8TextBox.Size = new System.Drawing.Size(100, 21); + this.E8TextBox.Size = new System.Drawing.Size(80, 21); this.E8TextBox.TabIndex = 23; // // label9 // this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(377, 60); + this.label9.Location = new System.Drawing.Point(333, 59); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(95, 12); this.label9.TabIndex = 22; @@ -827,15 +829,15 @@ namespace HighWayIot.Winform.UserControlPages // // E7TextBox // - this.E7TextBox.Location = new System.Drawing.Point(478, 56); + this.E7TextBox.Location = new System.Drawing.Point(434, 55); this.E7TextBox.Name = "E7TextBox"; - this.E7TextBox.Size = new System.Drawing.Size(100, 21); + this.E7TextBox.Size = new System.Drawing.Size(80, 21); this.E7TextBox.TabIndex = 21; // // label10 // this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(413, 32); + this.label10.Location = new System.Drawing.Point(369, 31); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(59, 12); this.label10.TabIndex = 20; @@ -843,15 +845,15 @@ namespace HighWayIot.Winform.UserControlPages // // E6TextBox // - this.E6TextBox.Location = new System.Drawing.Point(478, 29); + this.E6TextBox.Location = new System.Drawing.Point(434, 28); this.E6TextBox.Name = "E6TextBox"; - this.E6TextBox.Size = new System.Drawing.Size(100, 21); + this.E6TextBox.Size = new System.Drawing.Size(80, 21); this.E6TextBox.TabIndex = 19; // // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(182, 138); + this.label5.Location = new System.Drawing.Point(182, 139); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(59, 12); this.label5.TabIndex = 18; @@ -859,41 +861,41 @@ namespace HighWayIot.Winform.UserControlPages // // E5TextBox // - this.E5TextBox.Location = new System.Drawing.Point(247, 135); + this.E5TextBox.Location = new System.Drawing.Point(247, 136); this.E5TextBox.Name = "E5TextBox"; - this.E5TextBox.Size = new System.Drawing.Size(100, 21); + this.E5TextBox.Size = new System.Drawing.Size(80, 21); this.E5TextBox.TabIndex = 17; // // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(128, 114); + this.label4.Location = new System.Drawing.Point(182, 114); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(113, 12); + this.label4.Size = new System.Drawing.Size(59, 12); this.label4.TabIndex = 16; - this.label4.Text = "胶片贴合时间(0.1s)"; + this.label4.Text = "备用时间2"; // // E4TextBox // this.E4TextBox.Location = new System.Drawing.Point(247, 110); this.E4TextBox.Name = "E4TextBox"; - this.E4TextBox.Size = new System.Drawing.Size(100, 21); + this.E4TextBox.Size = new System.Drawing.Size(80, 21); this.E4TextBox.TabIndex = 15; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(116, 88); + this.label3.Location = new System.Drawing.Point(182, 87); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(125, 12); + this.label3.Size = new System.Drawing.Size(59, 12); this.label3.TabIndex = 14; - this.label3.Text = "贴合末横裁延时(0.1s)"; + this.label3.Text = "备用延时1"; // // E3TextBox // this.E3TextBox.Location = new System.Drawing.Point(247, 83); this.E3TextBox.Name = "E3TextBox"; - this.E3TextBox.Size = new System.Drawing.Size(100, 21); + this.E3TextBox.Size = new System.Drawing.Size(80, 21); this.E3TextBox.TabIndex = 13; // // label2 @@ -909,7 +911,7 @@ namespace HighWayIot.Winform.UserControlPages // this.E2TextBox.Location = new System.Drawing.Point(247, 56); this.E2TextBox.Name = "E2TextBox"; - this.E2TextBox.Size = new System.Drawing.Size(100, 21); + this.E2TextBox.Size = new System.Drawing.Size(80, 21); this.E2TextBox.TabIndex = 11; // // label1 @@ -925,7 +927,7 @@ namespace HighWayIot.Winform.UserControlPages // this.E1TextBox.Location = new System.Drawing.Point(247, 29); this.E1TextBox.Name = "E1TextBox"; - this.E1TextBox.Size = new System.Drawing.Size(100, 21); + this.E1TextBox.Size = new System.Drawing.Size(80, 21); this.E1TextBox.TabIndex = 9; // // PositionRadioButtonPanel @@ -1048,10 +1050,10 @@ namespace HighWayIot.Winform.UserControlPages this.groupbox5.Controls.Add(this.SpecNoLabel); this.groupbox5.Controls.Add(this.label19); this.groupbox5.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupbox5.Location = new System.Drawing.Point(1058, 0); + this.groupbox5.Location = new System.Drawing.Point(1149, 0); this.groupbox5.Margin = new System.Windows.Forms.Padding(0); this.groupbox5.Name = "groupbox5"; - this.groupbox5.Size = new System.Drawing.Size(658, 170); + this.groupbox5.Size = new System.Drawing.Size(750, 170); this.groupbox5.TabIndex = 5; this.groupbox5.TabStop = false; this.groupbox5.Text = "公共参数"; @@ -1332,11 +1334,11 @@ namespace HighWayIot.Winform.UserControlPages // label13 // this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(255, 86); + this.label13.Location = new System.Drawing.Point(273, 85); this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(53, 12); + this.label13.Size = new System.Drawing.Size(35, 12); this.label13.TabIndex = 37; - this.label13.Text = "减速距离"; + this.label13.Text = "备用1"; // // S3Check // @@ -1358,11 +1360,11 @@ namespace HighWayIot.Winform.UserControlPages // label12 // this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(255, 112); + this.label12.Location = new System.Drawing.Point(273, 112); this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(53, 12); + this.label12.Size = new System.Drawing.Size(35, 12); this.label12.TabIndex = 39; - this.label12.Text = "停止距离"; + this.label12.Text = "备用2"; // // TireWeightTextBox // @@ -1425,7 +1427,7 @@ namespace HighWayIot.Winform.UserControlPages this.tableLayoutPanel2.Name = "tableLayoutPanel2"; this.tableLayoutPanel2.RowCount = 1; this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(1722, 63); + this.tableLayoutPanel2.Size = new System.Drawing.Size(1905, 63); this.tableLayoutPanel2.TabIndex = 9; // // panel1 @@ -1437,10 +1439,10 @@ namespace HighWayIot.Winform.UserControlPages this.panel1.Controls.Add(this.UpdateWeightButton); this.panel1.Controls.Add(this.AddWeightButton); this.panel1.Controls.Add(this.DeleteWeightButton); - this.panel1.Location = new System.Drawing.Point(861, 0); + this.panel1.Location = new System.Drawing.Point(952, 0); this.panel1.Margin = new System.Windows.Forms.Padding(0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(861, 63); + this.panel1.Size = new System.Drawing.Size(953, 63); this.panel1.TabIndex = 5; // // label27 @@ -1488,7 +1490,7 @@ namespace HighWayIot.Winform.UserControlPages // DeleteWeightButton // this.DeleteWeightButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.DeleteWeightButton.Location = new System.Drawing.Point(746, 12); + this.DeleteWeightButton.Location = new System.Drawing.Point(838, 12); this.DeleteWeightButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.DeleteWeightButton.Name = "DeleteWeightButton"; this.DeleteWeightButton.Size = new System.Drawing.Size(103, 39); @@ -1497,6 +1499,121 @@ namespace HighWayIot.Winform.UserControlPages this.DeleteWeightButton.UseVisualStyleBackColor = true; this.DeleteWeightButton.Click += new System.EventHandler(this.DeleteWeightButton_Click); // + // Id + // + this.Id.DataPropertyName = "Id"; + this.Id.HeaderText = "ID"; + this.Id.Name = "Id"; + this.Id.ReadOnly = true; + this.Id.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.Id.Width = 40; + // + // MaterialCode + // + this.MaterialCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.MaterialCode.DataPropertyName = "MaterialCode"; + this.MaterialCode.HeaderText = "胶料编码"; + this.MaterialCode.Name = "MaterialCode"; + this.MaterialCode.ReadOnly = true; + this.MaterialCode.Resizable = System.Windows.Forms.DataGridViewTriState.False; + // + // MaterialName + // + this.MaterialName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.MaterialName.DataPropertyName = "MaterialName"; + this.MaterialName.HeaderText = "胶料名称"; + this.MaterialName.Name = "MaterialName"; + this.MaterialName.ReadOnly = true; + this.MaterialName.Resizable = System.Windows.Forms.DataGridViewTriState.False; + // + // MaterialType + // + this.MaterialType.DataPropertyName = "MaterialType"; + this.MaterialType.HeaderText = "胶料类型"; + this.MaterialType.Name = "MaterialType"; + this.MaterialType.ReadOnly = true; + this.MaterialType.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.MaterialType.Width = 89; + // + // SetThickness + // + this.SetThickness.DataPropertyName = "SetThickness"; + this.SetThickness.HeaderText = "厚度"; + this.SetThickness.Name = "SetThickness"; + this.SetThickness.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.SetThickness.Width = 59; + // + // SetWidth1 + // + this.SetWidth1.DataPropertyName = "SetWidth"; + this.SetWidth1.HeaderText = "宽度1"; + this.SetWidth1.Name = "SetWidth1"; + this.SetWidth1.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.SetWidth1.Width = 60; + // + // SetLayer1 + // + this.SetLayer1.DataPropertyName = "SetLayer"; + this.SetLayer1.HeaderText = "层数1"; + this.SetLayer1.Name = "SetLayer1"; + this.SetLayer1.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.SetLayer1.Width = 60; + // + // SetWidth2 + // + this.SetWidth2.DataPropertyName = "SetWidth2"; + this.SetWidth2.HeaderText = "宽度2"; + this.SetWidth2.Name = "SetWidth2"; + this.SetWidth2.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.SetWidth2.Width = 60; + // + // SetLayer2 + // + this.SetLayer2.DataPropertyName = "SetLayer2"; + this.SetLayer2.HeaderText = "层数2"; + this.SetLayer2.Name = "SetLayer2"; + this.SetLayer2.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.SetLayer2.Width = 60; + // + // SetWidth3 + // + this.SetWidth3.DataPropertyName = "SetWidth3"; + this.SetWidth3.HeaderText = "宽度3"; + this.SetWidth3.Name = "SetWidth3"; + this.SetWidth3.Width = 60; + // + // SetLayer3 + // + this.SetLayer3.DataPropertyName = "SetLayer3"; + this.SetLayer3.HeaderText = "层数3"; + this.SetLayer3.Name = "SetLayer3"; + this.SetLayer3.Width = 60; + // + // SetWeight + // + this.SetWeight.DataPropertyName = "SetWeight"; + this.SetWeight.HeaderText = "重量"; + this.SetWeight.Name = "SetWeight"; + this.SetWeight.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.SetWeight.Width = 70; + // + // SetError + // + this.SetError.DataPropertyName = "SetError"; + this.SetError.HeaderText = "公差"; + this.SetError.Name = "SetError"; + this.SetError.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.SetError.Width = 55; + // + // WeightIsUse + // + this.WeightIsUse.DataPropertyName = "IsUse"; + this.WeightIsUse.HeaderText = "启用"; + this.WeightIsUse.Name = "WeightIsUse"; + this.WeightIsUse.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.WeightIsUse.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + this.WeightIsUse.Width = 40; + // // RecipeConfigPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -1507,7 +1624,7 @@ namespace HighWayIot.Winform.UserControlPages this.Controls.Add(this.tableLayoutPanel1); this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "RecipeConfigPage"; - this.Size = new System.Drawing.Size(1722, 1066); + this.Size = new System.Drawing.Size(1905, 995); ((System.ComponentModel.ISupportInitialize)(this.WeightDataGridView)).EndInit(); this.ButtonPanel.ResumeLayout(false); this.ButtonPanel.PerformLayout(); @@ -1636,18 +1753,16 @@ namespace HighWayIot.Winform.UserControlPages private Label Station3MaterialName; private Label Station2MaterialName; private Label Station1MaterialName; - private DataGridViewTextBoxColumn Id; - private DataGridViewTextBoxColumn MaterialCode; - private DataGridViewTextBoxColumn MaterialName; - private DataGridViewTextBoxColumn MaterialType; - private DataGridViewTextBoxColumn SetThickness; - private DataGridViewTextBoxColumn SetWidth1; - private DataGridViewTextBoxColumn SetLayer1; - private DataGridViewTextBoxColumn SetWidth2; - private DataGridViewTextBoxColumn SetLayer2; - private DataGridViewTextBoxColumn SetWeight; - private DataGridViewTextBoxColumn SetError; - private DataGridViewCheckBoxColumn WeightIsUse; + private Label label20; + private TextBox E15TextBox; + private Label label24; + private TextBox E14TextBox; + private Label label25; + private TextBox E13TextBox; + private Label label33; + private TextBox E12TextBox; + private Label label35; + private TextBox E11TextBox; private DataGridViewTextBoxColumn RId; private DataGridViewTextBoxColumn RecipeCode; private DataGridViewTextBoxColumn RecipeName; @@ -1657,5 +1772,19 @@ namespace HighWayIot.Winform.UserControlPages private DataGridViewTextBoxColumn FixedWidth; private DataGridViewTextBoxColumn WeightError; private DataGridViewCheckBoxColumn IsUse; + private DataGridViewTextBoxColumn Id; + private DataGridViewTextBoxColumn MaterialCode; + private DataGridViewTextBoxColumn MaterialName; + private DataGridViewTextBoxColumn MaterialType; + private DataGridViewTextBoxColumn SetThickness; + private DataGridViewTextBoxColumn SetWidth1; + private DataGridViewTextBoxColumn SetLayer1; + private DataGridViewTextBoxColumn SetWidth2; + private DataGridViewTextBoxColumn SetLayer2; + private DataGridViewTextBoxColumn SetWidth3; + private DataGridViewTextBoxColumn SetLayer3; + private DataGridViewTextBoxColumn SetWeight; + private DataGridViewTextBoxColumn SetError; + private DataGridViewCheckBoxColumn WeightIsUse; } } diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs index 8c88da3..998f35a 100644 --- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs +++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.cs @@ -7,6 +7,7 @@ using HighWayIot.Winform.Business; using HighWayIot.Winform.MainForm; using HighWayIot.Winform.UserControlPages.RecipeConfigPages; using HighWayIot.Winform.UserControlPages.SysConfigPages; +using HslCommunication; using HslCommunication.Profinet.Siemens.S7PlusHelper; using Models; using System; @@ -127,33 +128,32 @@ namespace HighWayIot.Winform.UserControlPages WeightDataGridView.AutoGenerateColumns = false; RecipeLists = zxRecipeService.GetRecipeInfos(); - RecipeDataGridView.DataSource = null; - RecipeDataGridView.DataSource = RecipeLists; + RecipeDataGridView.DataSource = RecipeLists.OrderBy(x => x.RecipeName).ToList(); NowRecipeCode = RecipeDataGridView.Rows[0].Cells["RecipeCode"].Value.ToString(); InitPositionEntities(); - try - { - var res = PlcConnect.MelsecInstance2.Read("D200", 1); - if (res.IsSuccess) - { - //读取SPEC编号 - PlcSpecNoLabel.Text = PlcConnect.MelsecInstance2.ReadUInt32("D206").ToString(); - //读取SPEC名称 - PlcSpecNameLabel.Text = PlcConnect.MelsecInstance2.ReadString("D290", 10).ToString(); - } - else - { - - } - } - catch - { - PlcSpecNoLabel.Text = "PLC连接失败"; - PlcSpecNameLabel.Text = "PLC连接失败"; - } + //try + //{ + // OperateResult res = PlcConnect.ReadByte2("D200", 1); + // if (res.IsSuccess) + // { + // //读取SPEC编号 + // PlcSpecNoLabel.Text = PlcConnect.ReadUInt322("D206").Content.ToString(); + // //读取SPEC名称 + // PlcSpecNameLabel.Text = PlcConnect.ReadString2("D290", 10).Content.ToString(); + // } + // else + // { + // MessageBox.Show(res.Message); + // } + //} + //catch + //{ + // PlcSpecNoLabel.Text = "PLC连接失败"; + // PlcSpecNameLabel.Text = "PLC连接失败"; + //} openMixConfig = zxOpenMixMaterialService.GetInfos(); Station1MaterialName.Text = openMixConfig.Single(x => x.StationNo == 1).MaterialName; @@ -215,7 +215,7 @@ namespace HighWayIot.Winform.UserControlPages RecipeLists = zxRecipeService.GetRecipeInfos(); RecipeDataGridView.DataSource = null; - RecipeDataGridView.DataSource = RecipeLists; + RecipeDataGridView.DataSource = RecipeLists.OrderBy(x => x.RecipeName).ToList(); } } @@ -246,13 +246,15 @@ namespace HighWayIot.Winform.UserControlPages return; } + //删除成型信息 if (zxWeightService.GetWeightInfos(NowRecipeCode).Count > 0) { - if (MessageBox.Show("是否要删除其关联的所有称量信息?", "确认", MessageBoxButtons.OKCancel) == DialogResult.OK) + if (MessageBox.Show("是否要删除其关联的所有成型信息?", "确认", MessageBoxButtons.OKCancel) == DialogResult.OK) { if (zxWeightService.DeleteWeightInfoByRecipeCode(NowRecipeCode)) { - MessageBox.Show("称量信息删除成功"); + MessageBox.Show("成型信息删除成功"); + SqlLogHelper.AddLog($"成型信息删除成功 [{NowRecipeCode}]"); } else { @@ -261,6 +263,17 @@ namespace HighWayIot.Winform.UserControlPages } } + //删除配方字段信息 + if (!zxRecipeParaService.DeleteRecipeParaInfoByRecipeCode(NowRecipeCode)) + { + MessageBox.Show("配方信息删除失败"); + } + + if (!zxRecipePositionParaService.DeleteRecipePositionParaInfoByRecipeCode(NowRecipeCode)) + { + MessageBox.Show("配方工位信息删除失败"); + } + //删除硫化配方防止报错 List schedulingEntity = ZxSchedulingService.Instance.GetSchedulingInfo(); var updateInfos = schedulingEntity.Where(x => x.RecipeCode1 == NowRecipeCode || x.RecipeCode2 == NowRecipeCode).ToList(); @@ -283,6 +296,7 @@ namespace HighWayIot.Winform.UserControlPages if (zxRecipeService.DeleteRecipeInfoById(id)) { MessageBox.Show("配方信息删除成功!"); + SqlLogHelper.AddLog($"成型信息删除成功 [{NowRecipeCode}]"); } else { @@ -292,7 +306,7 @@ namespace HighWayIot.Winform.UserControlPages RecipeLists = zxRecipeService.GetRecipeInfos(); RecipeDataGridView.DataSource = null; - RecipeDataGridView.DataSource = RecipeLists; + RecipeDataGridView.DataSource = RecipeLists.OrderBy(x => x.RecipeName).ToList(); } /// @@ -338,6 +352,7 @@ namespace HighWayIot.Winform.UserControlPages paraentity.LightWidth = (int)entity.FixedWidth; zxRecipeParaService.UpdateRecipeParaInfo(paraentity); MessageBox.Show("配方更新成功!"); + SqlLogHelper.AddLog($"配方更新成功 [{NowRecipeCode}]"); } else { @@ -347,7 +362,7 @@ namespace HighWayIot.Winform.UserControlPages RecipeLists = zxRecipeService.GetRecipeInfos(); RecipeDataGridView.DataSource = null; - RecipeDataGridView.DataSource = RecipeLists; + RecipeDataGridView.DataSource = RecipeLists.OrderBy(x => x.RecipeName).ToList(); } /// @@ -359,7 +374,7 @@ namespace HighWayIot.Winform.UserControlPages { RecipeLists = zxRecipeService.GetRecipeInfos(); RecipeDataGridView.DataSource = null; - RecipeDataGridView.DataSource = RecipeLists; + RecipeDataGridView.DataSource = RecipeLists.OrderBy(x => x.RecipeName).ToList(); } #endregion @@ -385,7 +400,7 @@ namespace HighWayIot.Winform.UserControlPages if (form.OutValue == null) { return; - } + } //连同更新PLC字段信息 var config = openMixConfig.Where(x => x.MaterialName == form.OutValue.MaterialName).FirstOrDefault(); if (config != null) @@ -394,8 +409,12 @@ namespace HighWayIot.Winform.UserControlPages ZxRecipeParaEntity recipePara = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(form.OutValue.RecipeCode).FirstOrDefault(); var prop = recipePara.GetType().GetProperty($"S{config.StationNo + 1}"); prop.SetValue(recipePara, true); + if (form.OutValue.MaterialType == "胎面胶") + { + recipePara.TireWeight = Convert.ToSingle(form.OutValue.SetWeight); + } zxRecipeParaService.UpdateRecipeParaInfo(recipePara); - //更新字段 + //更新工位字段 var positionInfo = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.Position == config.StationNo && x.RecipeCode == NowRecipeCode); if(positionInfo.Count == 0) { @@ -403,10 +422,13 @@ namespace HighWayIot.Winform.UserControlPages { RecipeCode = NowRecipeCode, Position = config.StationNo, + E1 = 45, + E2 = 52, E5 = form.OutValue.SetLayer, E9 = (int)form.OutValue.SetWidth, E6 = form.OutValue.SetLayer2, E7 = (int)form.OutValue.SetWidth2, + E10 = 2900 }; zxRecipePositionParaService.InsertRecipePositionParaInfo(zxRecipePositionParaEntity); } @@ -452,14 +474,15 @@ namespace HighWayIot.Winform.UserControlPages return; } - if (MessageBox.Show($"确定要删除配方编号为 [{NowRecipeCode}] 物料编码为 [{s2}] 的称重信息?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) + if (MessageBox.Show($"确定要删除配方编号为 [{NowRecipeCode}] 物料编码为 [{s2}] 的成型信息?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } if (zxWeightService.DeleteWeightInfoById(id)) { - MessageBox.Show("配方信息删除成功!"); + MessageBox.Show("成型信息删除成功!"); + SqlLogHelper.AddLog($"成型信息删除成功 配方编号为[{NowRecipeCode}] 物料编码为[{s2}]"); } else { @@ -503,8 +526,10 @@ namespace HighWayIot.Winform.UserControlPages entity.SetThickness = decimal.Parse(Convert.ToString(nowRow.Cells["SetThickness"].Value ?? "0")); entity.SetWidth = decimal.Parse(Convert.ToString(nowRow.Cells["SetWidth1"].Value ?? "0")); entity.SetWidth2 = decimal.Parse(Convert.ToString(nowRow.Cells["SetWidth2"].Value ?? "0")); + entity.SetWidth3 = decimal.Parse(Convert.ToString(nowRow.Cells["SetWidth3"].Value ?? "0")); entity.SetLayer = int.Parse(Convert.ToString(nowRow.Cells["SetLayer1"].Value ?? "0")); entity.SetLayer2 = int.Parse(Convert.ToString(nowRow.Cells["SetLayer2"].Value ?? "0")); + entity.SetLayer3 = int.Parse(Convert.ToString(nowRow.Cells["SetLayer3"].Value ?? "0")); entity.SetWeight = decimal.Parse(Convert.ToString(nowRow.Cells["SetWeight"].Value ?? "0")); entity.SetError = decimal.Parse(Convert.ToString(nowRow.Cells["SetError"].Value ?? "0")); entity.IsUse = bool.Parse(Convert.ToString(nowRow.Cells["WeightIsUse"].Value)); @@ -518,6 +543,13 @@ namespace HighWayIot.Winform.UserControlPages if (zxWeightService.UpdateWeightInfo(entity)) { + //是否更新重量 + if (entity.MaterialType == "胎面胶") + { + ZxRecipeParaEntity recipePara = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(entity.RecipeCode).FirstOrDefault(); + recipePara.TireWeight = Convert.ToSingle(entity.SetWeight); + zxRecipeParaService.UpdateRecipeParaInfo(recipePara); + } //连同更新PLC字段信息 var config = openMixConfig.Where(x => x.MaterialName == entity.MaterialName).FirstOrDefault(); if (config != null) @@ -547,6 +579,7 @@ namespace HighWayIot.Winform.UserControlPages } } MessageBox.Show("成型信息更新成功!"); + SqlLogHelper.AddLog($"成型信息更新成功 配方编号为[{NowRecipeCode}] 物料编码为[{entity.MaterialCode}]"); } else { @@ -743,6 +776,7 @@ namespace HighWayIot.Winform.UserControlPages if (flag1 && flag2) { BaseForm.LogRefreshAction.Invoke("更新成功"); + SqlLogHelper.AddLog($"配方参数保存成功 配方编号为[{NowRecipeCode}]"); } else { @@ -816,6 +850,11 @@ namespace HighWayIot.Winform.UserControlPages E8TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E8); E9TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E9); E10TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E10); + E11TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E11); + E12TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E12); + E13TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E13); + E14TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E14); + E15TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E15); } /// @@ -860,6 +899,11 @@ namespace HighWayIot.Winform.UserControlPages e.E8 = GeneralUtils.StringNullOrToInt(E8TextBox.Text); e.E9 = GeneralUtils.StringNullOrToInt(E9TextBox.Text); e.E10 = GeneralUtils.StringNullOrToInt(E10TextBox.Text); + e.E11 = GeneralUtils.StringNullOrToInt(E11TextBox.Text); + e.E12 = GeneralUtils.StringNullOrToInt(E12TextBox.Text); + e.E13 = GeneralUtils.StringNullOrToInt(E13TextBox.Text); + e.E14 = GeneralUtils.StringNullOrToInt(E14TextBox.Text); + e.E15 = GeneralUtils.StringNullOrToInt(E15TextBox.Text); e.Position = GetSelectIndex(); e.RecipeCode = NowRecipeCode; @@ -1056,6 +1100,11 @@ namespace HighWayIot.Winform.UserControlPages E8 = entity.E8, E9 = entity.E9, E10 = entity.E10, + E11 = entity.E11, + E12 = entity.E12, + E13 = entity.E13, + E14 = entity.E14, + E15 = entity.E15, Position = entity.Position, }; PositionParaCopyBoard.Add(clone); @@ -1120,7 +1169,7 @@ namespace HighWayIot.Winform.UserControlPages { return; } - if (!PlcConnect.MelsecInstance2.Read("D200", 1).IsSuccess) + if (!PlcConnect.ReadByte2("D200", 1).IsSuccess) { MessageBox.Show("PLC未连接"); return; @@ -1130,6 +1179,7 @@ namespace HighWayIot.Winform.UserControlPages if (recipeParaHelper.UploadToPLC(zxRecipeParaEntity, zxRecipePositionParaEntity)) { MessageBox.Show("下发到PLC成功"); + SqlLogHelper.AddLog($"配方参数下发到PLC 配方编号为[{NowRecipeCode}]"); } else { @@ -1150,7 +1200,7 @@ namespace HighWayIot.Winform.UserControlPages { return; } - if (!PlcConnect.MelsecInstance2.Read("D200", 1).IsSuccess) + if (!PlcConnect.ReadByte2("D200", 1).IsSuccess) { MessageBox.Show("PLC未连接"); return; @@ -1158,6 +1208,7 @@ namespace HighWayIot.Winform.UserControlPages zxRecipePositionParaEntity = recipeParaHelper.DownLoadFormPlc(ref zxRecipeParaEntity); SetPublicParaValue(zxRecipeParaEntity); SetPrivateParaValue(zxRecipePositionParaEntity.First(x => x.Position == GetSelectIndex())); + SqlLogHelper.AddLog($"配方参数从PLC下载到本地 配方编号为[{NowRecipeCode}]"); PlcSpecNameLabel.Text = zxRecipeParaEntity.SpecName.Trim(); PlcSpecNoLabel.Text = zxRecipeParaEntity.SpecCode.Trim(); } @@ -1610,5 +1661,6 @@ namespace HighWayIot.Winform.UserControlPages } #endregion + } } diff --git a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.resx b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.resx index 74880e6..d67a87b 100644 --- a/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.resx +++ b/HighWayIot.Winform/UserControlPages/RecipeConfigPages/RecipeConfigPage.resx @@ -144,6 +144,12 @@ True + + True + + + True + True diff --git a/HighWayIot.Winform/UserControlPages/TestPage.cs b/HighWayIot.Winform/UserControlPages/TestPage.cs index 29a6362..995e474 100644 --- a/HighWayIot.Winform/UserControlPages/TestPage.cs +++ b/HighWayIot.Winform/UserControlPages/TestPage.cs @@ -1,11 +1,14 @@ using HighWayIot.Log4net; using HighWayIot.Plc; using HighWayIot.Plc.PlcHelper; +using HighWayIot.Repository.domain; +using HighWayIot.Repository.service; using HighWayIot.Rfid; using HighWayIot.TouchSocket; using HighWayIot.Winform.Business; using HighWayIot.Winform.Properties; using HslCommunication; +using Models; using System; using System.Collections; using System.Collections.Generic; @@ -63,30 +66,10 @@ namespace HighWayIot.Winform.UserControlPages /// private void button1_Click(object sender, EventArgs e) { - OperateResult PlcResult = PlcConnect.MelsecInstance2.Read("B230", 2); - - if (PlcResult.IsSuccess) - { - byte[] bytes = PlcResult.Content; - Console.WriteLine("长度" + bytes.Length.ToString()); - } - else - { - Console.WriteLine("读取失败"); - } - - WorkStationHelper helper = new WorkStationHelper(); - bool[] res = helper.ReadStationSingal(); - foreach(var r in res) - { - Console.WriteLine(r.ToString()); - } - - //var list = xmlUtil.ConfigReader(); - //foreach (var item in list) - //{ - // Console.WriteLine(item.RoleIndex + item.PageName); - //} + MonitorInsert( + ZxRecipeService.Instance.GetRecipeInfos().FirstOrDefault().RecipeCode, + 10.ToString() + ); } /// @@ -96,8 +79,8 @@ namespace HighWayIot.Winform.UserControlPages /// private void button2_Click(object sender, EventArgs e) { - var a = _touchSocketTcpClient.Send($"10.20.48.{RFIDtext.Text}", _RfidDataAnalyse.Send02H(1000)); - LogHelper.Instance.Info($"10.20.48.{RFIDtext.Text} 发送" + (a ? "成功" : "失败")); + var a = _touchSocketTcpClient.Send($"192.168.0.{RFIDtext.Text}", _RfidDataAnalyse.Send02H(1000)); + LogHelper.Instance.Info($"192.168.0.{RFIDtext.Text} 发送" + (a ? "成功" : "失败")); } /// @@ -107,7 +90,9 @@ namespace HighWayIot.Winform.UserControlPages /// private void button3_Click(object sender, EventArgs e) { - MessageBox.Show(PlcConnect.MelsecInstance2.Read("D200", 1).IsSuccess.ToString()); + //MessageBox.Show(PlcConnect.ReadByte2("D200", 1).IsSuccess.ToString()); + var res = PlcConnect.PlcWrite2("D310", 123, DataTypeEnum.UInt16); + MessageBox.Show(res.IsSuccess.ToString()); } /// @@ -161,6 +146,33 @@ namespace HighWayIot.Winform.UserControlPages //PlcShowValue.Text = res; } + /// + /// 监控画面信息插入 + /// + public void MonitorInsert(string recipeCode, string deviceNo) + { + ZxRecipeEntity recipeEntity = ZxRecipeService.Instance.GetRecipeInfosByRecipeCode(recipeCode).FirstOrDefault(); + if (recipeEntity == null) + { + return; + } + + ZxDailyReportEntity entity = new ZxDailyReportEntity() + { + Uuid = Guid.NewGuid().ToString("N"), + VulcanizationNo = deviceNo, + StartTime = DateTime.Now, + RecipeName = recipeEntity.RecipeName, + RecipeCode = recipeEntity.RecipeCode, + SpecCode = recipeEntity.RecipeSpecCode, + DeviceNo = RecipeSendBusiness.RecipeNeededVehicleNo, + RawTireWeight = (int)ZxRecipeParaService.Instance.GetRecipeParaInfoByRecipeCode(recipeCode).FirstOrDefault()?.TireWeight, + IsDone = 0 + }; + + ZxDailyReportService.Instance.InsertDailyReportInfo(entity); + } + /// /// PLC写入按钮 /// diff --git a/HighWayIot.Winform/packages.config b/HighWayIot.Winform/packages.config new file mode 100644 index 0000000..7d4c479 --- /dev/null +++ b/HighWayIot.Winform/packages.config @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file