报警信息推送,料架表更新
This commit is contained in:
@@ -8,7 +8,6 @@ using Mapster;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
|
||||
namespace DOAN.Service.PBL
|
||||
{
|
||||
/// <summary>
|
||||
@@ -17,16 +16,17 @@ namespace DOAN.Service.PBL
|
||||
[AppService(ServiceType = typeof(IMESInteractionServcie), ServiceLifetime = LifeTime.Transient)]
|
||||
public class MESInteractionServcie : BaseService<Storagelocation>, IMESInteractionServcie
|
||||
{
|
||||
private readonly IHubContext<PBLhub> notificationHubContext;
|
||||
public MESInteractionServcie(IHubContext<PBLhub> _notificationHubContext) {
|
||||
private readonly IHubContext<PBLhub> notificationHubContext;
|
||||
|
||||
notificationHubContext= _notificationHubContext;
|
||||
public MESInteractionServcie(IHubContext<PBLhub> _notificationHubContext)
|
||||
{
|
||||
notificationHubContext = _notificationHubContext;
|
||||
}
|
||||
|
||||
public bool TestPLc(string address, PLCTool pLCTool)
|
||||
{
|
||||
bool isSucesss = pLCTool.ReadBit(address);
|
||||
return isSucesss;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -46,17 +46,24 @@ namespace DOAN.Service.PBL
|
||||
|
||||
// 2.根据总成零件号 ,版本 查询对应零件号,使得对应料架亮灯
|
||||
|
||||
// 同一个会有多个料架
|
||||
// 同一个会有多个料架
|
||||
//镜壳 料架层
|
||||
List<Storagelocation> MirrorshellShelfList = Context.Queryable<Storagelocation>().Where(it => it.Partnumber ==
|
||||
SqlFunc.Subqueryable<Billofmaterials>().Where(It => It.Productcode == light.AssemblyPartNumber).Select(it => it.MirrorshellCode)).ToList();
|
||||
List<Storagelocation> MirrorshellShelfList = Context
|
||||
.Queryable<Storagelocation>()
|
||||
.Where(it =>
|
||||
it.Partnumber
|
||||
== SqlFunc
|
||||
.Subqueryable<Billofmaterials>()
|
||||
.Where(It => It.Productcode == light.AssemblyPartNumber)
|
||||
.Select(it => it.MirrorshellCode)
|
||||
)
|
||||
.ToList();
|
||||
|
||||
//镜体 料架
|
||||
// Storagelocation MirrorshellBody = Context.Queryable<Storagelocation>().Where(it => it.Partnumber ==
|
||||
// SqlFunc.Subqueryable<Billofmaterials>().Where(It => It.Productcode == light.AssemblyPartNumber && It.Version == light.Version).Select(it => it.MirrorbodyCode)).First();
|
||||
if (MirrorshellShelfList != null && MirrorshellShelfList.Count() > 0)
|
||||
{
|
||||
|
||||
foreach (var item1 in MirrorshellShelfList)
|
||||
{
|
||||
// 3.对应料架亮灯
|
||||
@@ -70,10 +77,8 @@ namespace DOAN.Service.PBL
|
||||
item1.IsLight = 1;
|
||||
|
||||
Context.Updateable(item1).ExecuteCommand();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//亮灯日志
|
||||
Light_Log light_Log = new Light_Log();
|
||||
light_Log.Id = XUEHUA;
|
||||
@@ -84,7 +89,6 @@ namespace DOAN.Service.PBL
|
||||
light_Log.CreatedTime = DateTime.Now;
|
||||
light_Log.IsSuccess = isSucesss;
|
||||
|
||||
|
||||
//Light_Log light_Log2 = new Light_Log();
|
||||
//light_Log2.Id = XUEHUA;
|
||||
//light_Log2.LightOperation = 1;
|
||||
@@ -98,25 +102,22 @@ namespace DOAN.Service.PBL
|
||||
//light_Log2.IsSuccess = isSucesss;
|
||||
//Context.Insertable(light_Log2).ExecuteCommand();
|
||||
result += Context.Insertable(light_Log).ExecuteCommand();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// 发送socket 通知
|
||||
|
||||
string message=$"MES产品编号{light.AssemblyPartNumber}或者版本{light.Version},在PBL中找不到。请维护PBL料架信息";
|
||||
string message =
|
||||
$"MES产品编号{light.AssemblyPartNumber}或者版本{light.Version},在PBL中找不到。请维护PBL料架信息";
|
||||
notificationHubContext.Clients.All.SendAsync("PBL_bom_except", message);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return result > 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// MES灭灯
|
||||
/// </summary>
|
||||
@@ -133,10 +134,13 @@ namespace DOAN.Service.PBL
|
||||
Context.Insertable(item).ExecuteCommand();
|
||||
|
||||
//2 找到对应的库存最大料架 灭灯
|
||||
Storagelocation storagelocation = Context.Queryable<Storagelocation>().Where(it => it.Partnumber.Contains(scan_code)).OrderByDescending(it => it.PackageNum).First();
|
||||
Storagelocation storagelocation = Context
|
||||
.Queryable<Storagelocation>()
|
||||
.Where(it => it.Partnumber.Contains(scan_code))
|
||||
.OrderByDescending(it => it.PackageNum)
|
||||
.First();
|
||||
if (storagelocation != null)
|
||||
{
|
||||
|
||||
// TODO PLC 交互
|
||||
bool isSuccess = pLCTool.WriteBit(storagelocation.PlcAddress, false);
|
||||
|
||||
@@ -153,14 +157,16 @@ namespace DOAN.Service.PBL
|
||||
int[] ids = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||
if (ids.Contains(storagelocation.Id))
|
||||
{
|
||||
Context.Updateable<Storagelocation>().SetColumns(it=>it.IsLight == 0).Where(it=>it.Partnumber == storagelocation.Partnumber).ExecuteCommand();
|
||||
Context
|
||||
.Updateable<Storagelocation>()
|
||||
.SetColumns(it => it.IsLight == 0)
|
||||
.Where(it => it.Partnumber == storagelocation.Partnumber)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
Context.Updateable(storagelocation).ExecuteCommand();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//灭灯日志
|
||||
Light_Log light_Log = new Light_Log();
|
||||
@@ -179,9 +185,6 @@ namespace DOAN.Service.PBL
|
||||
return false;
|
||||
}
|
||||
return result > 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user