This commit is contained in:
qianhao.xu
2024-11-07 20:17:39 +08:00
parent f664b5beac
commit 54840baf1b
5 changed files with 84 additions and 5 deletions

View File

@@ -47,6 +47,15 @@ namespace DOAN.Model.PBL
[SugarColumn(ColumnName = "mirrorbody_code")] [SugarColumn(ColumnName = "mirrorbody_code")]
public string MirrorbodyCode { get; set; } public string MirrorbodyCode { get; set; }
/// <summary>
/// 版本
/// </summary>
[SugarColumn(ColumnName = "version")]
public int Version { get; set; }
/// <summary> /// <summary>
/// 创建人 /// 创建人
/// </summary> /// </summary>

View File

@@ -26,6 +26,12 @@ namespace DOAN.Model.PBL.Dto
public string AssemblyPartNumber { get; set; } public string AssemblyPartNumber { get; set; }
/// <summary>
/// 版本号
/// </summary>
public int Version { get; set; }

View File

@@ -38,6 +38,13 @@ namespace DOAN.Model.PBL
[SugarColumn(ColumnName = "AssemblyPartNumber")] [SugarColumn(ColumnName = "AssemblyPartNumber")]
public string AssemblyPartNumber { get; set; } public string AssemblyPartNumber { get; set; }
/// <summary>
/// 版本号
/// </summary>
[SugarColumn(ColumnName = "Version")]
public int Version { get; set; }
/// <summary> /// <summary>
/// 扫描scancode /// 扫描scancode
/// </summary> /// </summary>

View File

@@ -26,20 +26,27 @@ namespace DOAN.Service.PBL
item.CreatedTime= DateTime.Now; item.CreatedTime= DateTime.Now;
Context.Insertable(item).ExecuteCommand(); Context.Insertable(item).ExecuteCommand();
// 2.根据总成零件号 查询对应零件号,使得对应料架亮灯 // 2.根据总成零件号 ,版本 查询对应零件号,使得对应料架亮灯
//镜壳 料架 //镜壳 料架
Storagelocation MirrorshellShelf = Context.Queryable<Storagelocation>().Where(it => it.Partnumber == Storagelocation MirrorshellShelf = Context.Queryable<Storagelocation>().Where(it => it.Partnumber ==
SqlFunc.Subqueryable<Billofmaterials>().Where(It => It.Productcode == light.AssemblyPartNumber).Select(it => it.MirrorshellCode)).First(); SqlFunc.Subqueryable<Billofmaterials>().Where(It => It.Productcode == light.AssemblyPartNumber&&It.Version==light.Version).Select(it => it.MirrorshellCode)).First();
//镜体 料架 //镜体 料架
Storagelocation MirrorshellBody = Context.Queryable<Storagelocation>().Where(it => it.Partnumber == Storagelocation MirrorshellBody = Context.Queryable<Storagelocation>().Where(it => it.Partnumber ==
SqlFunc.Subqueryable<Billofmaterials>().Where(It => It.Productcode == light.AssemblyPartNumber).Select(it => it.MirrorbodyCode)).First(); SqlFunc.Subqueryable<Billofmaterials>().Where(It => It.Productcode == light.AssemblyPartNumber&&It.Version == light.Version).Select(it => it.MirrorbodyCode)).First();
// 3.对应料架亮灯 // 3.对应料架亮灯
//TODO PLC 交互 //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 light_Log = new Light_Log();
light_Log.Id = XUEHUA; light_Log.Id = XUEHUA;

View File

@@ -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();
}
}
}