From 54840baf1b4b65bd17bcbb06a0288d481fdbbc9e Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Thu, 7 Nov 2024 20:17:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DOAN.Model/PBL/Billofmaterials.cs | 9 ++++ DOAN.Model/PBL/Dto/LightUp.cs | 6 +++ DOAN.Model/PBL/MES_Interaction.cs | 7 ++++ DOAN.Service/PBL/MESInteractionServcie.cs | 17 +++++--- Infrastructure/PLC/PCLTool.cs | 50 +++++++++++++++++++++++ 5 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 Infrastructure/PLC/PCLTool.cs diff --git a/DOAN.Model/PBL/Billofmaterials.cs b/DOAN.Model/PBL/Billofmaterials.cs index 54e3e27..5f88c32 100644 --- a/DOAN.Model/PBL/Billofmaterials.cs +++ b/DOAN.Model/PBL/Billofmaterials.cs @@ -47,6 +47,15 @@ namespace DOAN.Model.PBL [SugarColumn(ColumnName = "mirrorbody_code")] public string MirrorbodyCode { get; set; } + + + /// + /// 版本 + /// + [SugarColumn(ColumnName = "version")] + public int Version { get; set; } + + /// /// 创建人 /// diff --git a/DOAN.Model/PBL/Dto/LightUp.cs b/DOAN.Model/PBL/Dto/LightUp.cs index 3e720ef..088100d 100644 --- a/DOAN.Model/PBL/Dto/LightUp.cs +++ b/DOAN.Model/PBL/Dto/LightUp.cs @@ -26,6 +26,12 @@ namespace DOAN.Model.PBL.Dto public string AssemblyPartNumber { get; set; } + /// + /// 版本号 + /// + public int Version { get; set; } + + diff --git a/DOAN.Model/PBL/MES_Interaction.cs b/DOAN.Model/PBL/MES_Interaction.cs index 4f0ae66..cc264cb 100644 --- a/DOAN.Model/PBL/MES_Interaction.cs +++ b/DOAN.Model/PBL/MES_Interaction.cs @@ -38,6 +38,13 @@ namespace DOAN.Model.PBL [SugarColumn(ColumnName = "AssemblyPartNumber")] public string AssemblyPartNumber { get; set; } + /// + /// 版本号 + /// + [SugarColumn(ColumnName = "Version")] + public int Version { get; set; } + + /// /// 扫描scancode /// diff --git a/DOAN.Service/PBL/MESInteractionServcie.cs b/DOAN.Service/PBL/MESInteractionServcie.cs index ba11536..1c1bbdc 100644 --- a/DOAN.Service/PBL/MESInteractionServcie.cs +++ b/DOAN.Service/PBL/MESInteractionServcie.cs @@ -26,20 +26,27 @@ namespace DOAN.Service.PBL item.CreatedTime= DateTime.Now; Context.Insertable(item).ExecuteCommand(); - // 2.根据总成零件号 查询对应零件号,使得对应料架亮灯 + // 2.根据总成零件号 ,版本 查询对应零件号,使得对应料架亮灯 //镜壳 料架 Storagelocation MirrorshellShelf = Context.Queryable().Where(it => it.Partnumber == - SqlFunc.Subqueryable().Where(It => It.Productcode == light.AssemblyPartNumber).Select(it => it.MirrorshellCode)).First(); + SqlFunc.Subqueryable().Where(It => It.Productcode == light.AssemblyPartNumber&&It.Version==light.Version).Select(it => it.MirrorshellCode)).First(); //镜体 料架 Storagelocation MirrorshellBody = Context.Queryable().Where(it => it.Partnumber == - SqlFunc.Subqueryable().Where(It => It.Productcode == light.AssemblyPartNumber).Select(it => it.MirrorbodyCode)).First(); + SqlFunc.Subqueryable().Where(It => It.Productcode == light.AssemblyPartNumber&&It.Version == light.Version).Select(it => it.MirrorbodyCode)).First(); // 3.对应料架亮灯 - + //TODO PLC 交互 - + // 对应料架 亮灯字段 + MirrorshellShelf.IsLight = 1; + MirrorshellBody.IsLight = 1; + Context.Insertable(MirrorshellShelf).ExecuteCommand(); + Context.Insertable(MirrorshellBody).ExecuteCommand(); + // 通知PLC + + //亮灯日志 Light_Log light_Log = new Light_Log(); light_Log.Id = XUEHUA; diff --git a/Infrastructure/PLC/PCLTool.cs b/Infrastructure/PLC/PCLTool.cs new file mode 100644 index 0000000..1017293 --- /dev/null +++ b/Infrastructure/PLC/PCLTool.cs @@ -0,0 +1,50 @@ +using HslCommunication; +using HslCommunication.Profinet.Siemens; +using Infrastructure; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DOAN.Infrastructure.PLC +{ + public class PCLTool + { + + + // private NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); + + public static SiemensS7Net siemensTcpNet = null; + public bool ConnectPLC() + { + siemensTcpNet= new SiemensS7Net(SiemensPLCS.S1200, "192.168.0.100") + { + ConnectTimeOut = 5000 + }; + OperateResult connect = siemensTcpNet.ConnectServer(); + if (connect.IsSuccess) + { + // 连接成功 + Console.WriteLine("connect success"); + return true; + } + else + { + // 连接失败,输出原因 + Console.WriteLine("connect failed:" + connect.Message); + return false; + } + + + + } + + public void ConnectClose() + { + siemensTcpNet.ConnectClose(); + + } + + } +}