亮灯日志与报警逻辑,亮灯灭灯逻辑修改
This commit is contained in:
@@ -21,6 +21,8 @@ namespace DOAN.Model.PBL.Dto
|
|||||||
|
|
||||||
public string ShelfCode { get; set; }
|
public string ShelfCode { get; set; }
|
||||||
|
|
||||||
|
public string LayerNum { get; set; }
|
||||||
|
|
||||||
public string Operationer { get; set; }
|
public string Operationer { get; set; }
|
||||||
|
|
||||||
public DateTime? CreatedTime { get; set; }
|
public DateTime? CreatedTime { get; set; }
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ namespace DOAN.Model.PBL
|
|||||||
[SugarColumn(ColumnName = "shelf_code")]
|
[SugarColumn(ColumnName = "shelf_code")]
|
||||||
public string ShelfCode { get; set; }
|
public string ShelfCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 层号
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "layer_num")]
|
||||||
|
public string LayerNum { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PBL系统、人工
|
/// PBL系统、人工
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ using DOAN.Service.PBL.IService;
|
|||||||
using DOAN.ServiceCore.Signalr;
|
using DOAN.ServiceCore.Signalr;
|
||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
namespace DOAN.Service.PBL
|
namespace DOAN.Service.PBL
|
||||||
{
|
{
|
||||||
@@ -43,11 +45,7 @@ namespace DOAN.Service.PBL
|
|||||||
item.Id = XUEHUA;
|
item.Id = XUEHUA;
|
||||||
item.CreatedTime = DateTime.Now;
|
item.CreatedTime = DateTime.Now;
|
||||||
Context.Insertable(item).ExecuteCommand();
|
Context.Insertable(item).ExecuteCommand();
|
||||||
|
|
||||||
// 2.根据总成零件号 ,版本 查询对应零件号,使得对应料架亮灯
|
// 2.根据总成零件号 ,版本 查询对应零件号,使得对应料架亮灯
|
||||||
|
|
||||||
// 同一个会有多个料架
|
|
||||||
//镜壳 料架层
|
|
||||||
List<Storagelocation> MirrorshellShelfList = Context
|
List<Storagelocation> MirrorshellShelfList = Context
|
||||||
.Queryable<Storagelocation>()
|
.Queryable<Storagelocation>()
|
||||||
.Where(it =>
|
.Where(it =>
|
||||||
@@ -58,63 +56,59 @@ namespace DOAN.Service.PBL
|
|||||||
.Select(it => it.MirrorshellCode)
|
.Select(it => it.MirrorshellCode)
|
||||||
)
|
)
|
||||||
.ToList();
|
.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)
|
if (MirrorshellShelfList != null && MirrorshellShelfList.Count() > 0)
|
||||||
{
|
{
|
||||||
foreach (var item1 in MirrorshellShelfList)
|
Storagelocation storagelocation = new();
|
||||||
|
// 是否合并料架
|
||||||
|
bool isMergeRack = MirrorshellShelfList.Count > 1;
|
||||||
|
if (isMergeRack)
|
||||||
{
|
{
|
||||||
// 3.对应料架亮灯
|
// 合并料架 判断先进先出
|
||||||
|
foreach(var shelf in MirrorshellShelfList)
|
||||||
//TODO PLC 交互
|
|
||||||
// 对应料架 亮灯字段
|
|
||||||
// 通知PLC
|
|
||||||
bool isSucesss = pLCTool.WriteBit(item1.PlcAddress, true);
|
|
||||||
if (isSucesss)
|
|
||||||
{
|
{
|
||||||
item1.IsLight = 1;
|
// 第一个有箱子的
|
||||||
|
if(shelf.PackageNum > 0)
|
||||||
Context.Updateable(item1).ExecuteCommand();
|
{
|
||||||
|
storagelocation = shelf;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (storagelocation.RackCode == null)
|
||||||
|
{
|
||||||
|
storagelocation = MirrorshellShelfList[^1];
|
||||||
}
|
}
|
||||||
|
|
||||||
//亮灯日志
|
|
||||||
Light_Log light_Log = new Light_Log();
|
|
||||||
light_Log.Id = XUEHUA;
|
|
||||||
light_Log.LightOperation = 1;
|
|
||||||
light_Log.ShelfCode = item1.RackCode;
|
|
||||||
light_Log.LayerNum = item1.LayerNum;
|
|
||||||
light_Log.Operationer = "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;
|
|
||||||
|
|
||||||
//light_Log2.ShelfCode = item1.RackCode;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//light_Log2.Operationer = "PBL";
|
|
||||||
//light_Log2.CreatedTime = DateTime.Now;
|
|
||||||
//light_Log2.IsSuccess = isSucesss;
|
|
||||||
//Context.Insertable(light_Log2).ExecuteCommand();
|
|
||||||
result += Context.Insertable(light_Log).ExecuteCommand();
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 单独料架
|
||||||
|
storagelocation = MirrorshellShelfList[0];
|
||||||
|
}
|
||||||
|
// 3.对应料架亮灯
|
||||||
|
bool isSucesss = pLCTool.WriteBit(storagelocation.PlcAddress, true);
|
||||||
|
if (isSucesss) {
|
||||||
|
storagelocation.IsLight = 1;
|
||||||
|
result += Context.Updateable(storagelocation).ExecuteCommand();
|
||||||
|
}
|
||||||
|
//亮灯日志
|
||||||
|
Light_Log light_Log = new Light_Log();
|
||||||
|
light_Log.Id = XUEHUA;
|
||||||
|
light_Log.LightOperation = 1;
|
||||||
|
light_Log.Operationer = "PBL";
|
||||||
|
light_Log.CreatedTime = DateTime.Now;
|
||||||
|
light_Log.ShelfCode = storagelocation.RackCode;
|
||||||
|
light_Log.LayerNum = storagelocation.LayerNum;
|
||||||
|
light_Log.IsSuccess = isSucesss;
|
||||||
|
result += Context.Insertable(light_Log).ExecuteCommand();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 发送socket 通知
|
// 发送socket 通知
|
||||||
|
|
||||||
string message =
|
string message =
|
||||||
$"MES产品编号{light.AssemblyPartNumber}或者版本{light.Version},在PBL中找不到。请维护PBL料架信息";
|
$"MES产品编号{light.AssemblyPartNumber}或者版本{light.Version},在PBL中找不到。请维护PBL料架信息--{DateTime.Now}";
|
||||||
notificationHubContext.Clients.All.SendAsync("PBL_bom_except", message);
|
notificationHubContext.Clients.All.SendAsync("PBL_bom_except", message);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result > 0;
|
return result > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,58 +126,39 @@ namespace DOAN.Service.PBL
|
|||||||
item.ScanCode = scan_code;
|
item.ScanCode = scan_code;
|
||||||
item.CreatedTime = DateTime.Now;
|
item.CreatedTime = DateTime.Now;
|
||||||
Context.Insertable(item).ExecuteCommand();
|
Context.Insertable(item).ExecuteCommand();
|
||||||
|
//2 找到对应的亮着的料架 进行灭灯
|
||||||
//2 找到对应的库存最大料架 灭灯
|
|
||||||
Storagelocation storagelocation = Context
|
Storagelocation storagelocation = Context
|
||||||
.Queryable<Storagelocation>()
|
.Queryable<Storagelocation>()
|
||||||
.Where(it => it.Partnumber.Contains(scan_code))
|
.Where(it => it.Partnumber.Contains(scan_code))
|
||||||
.OrderByDescending(it => it.PackageNum)
|
.Where(it => it.IsLight == 1)
|
||||||
.First();
|
.First();
|
||||||
if (storagelocation != null)
|
if (storagelocation == null)
|
||||||
{
|
|
||||||
// TODO PLC 交互
|
|
||||||
bool isSuccess = pLCTool.WriteBit(storagelocation.PlcAddress, false);
|
|
||||||
|
|
||||||
if (isSuccess)
|
|
||||||
{
|
|
||||||
storagelocation.IsLight = 0;
|
|
||||||
// storagelocation.PackageNum -= 1;
|
|
||||||
//if (storagelocation.PackageNum < 0)
|
|
||||||
//{
|
|
||||||
// storagelocation.PackageNum = 0;
|
|
||||||
//}
|
|
||||||
//3 扣减对应的库存
|
|
||||||
// 合并货架的id
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Context.Updateable(storagelocation).ExecuteCommand();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//灭灯日志
|
|
||||||
Light_Log light_Log = new Light_Log();
|
|
||||||
light_Log.Id = XUEHUA;
|
|
||||||
light_Log.LightOperation = 2;
|
|
||||||
light_Log.LayerNum = 1;
|
|
||||||
light_Log.ShelfCode = storagelocation.RackCode;
|
|
||||||
|
|
||||||
light_Log.IsSuccess = isSuccess;
|
|
||||||
light_Log.Operationer = "PBL";
|
|
||||||
light_Log.CreatedTime = DateTime.Now;
|
|
||||||
result += Context.Insertable(light_Log).ExecuteCommand();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
// 发送socket 通知
|
||||||
|
string message =
|
||||||
|
$"未找到{scan_code}对应的亮灯料架。请检查信息--{DateTime.Now}";
|
||||||
|
notificationHubContext.Clients.All.SendAsync("PBL_bom_except", message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// TODO PLC 交互
|
||||||
|
bool isSuccess = pLCTool.WriteBit(storagelocation.PlcAddress, false);
|
||||||
|
if (isSuccess)
|
||||||
|
{
|
||||||
|
storagelocation.IsLight = 0;
|
||||||
|
result += Context.Updateable(storagelocation).ExecuteCommand();
|
||||||
|
}
|
||||||
|
//灭灯日志
|
||||||
|
Light_Log light_Log = new Light_Log
|
||||||
|
{
|
||||||
|
Id = XUEHUA,
|
||||||
|
LightOperation = 2,
|
||||||
|
LayerNum = storagelocation.LayerNum,
|
||||||
|
ShelfCode = storagelocation.RackCode,
|
||||||
|
IsSuccess = isSuccess,
|
||||||
|
Operationer = "PBL",
|
||||||
|
CreatedTime = DateTime.Now
|
||||||
|
};
|
||||||
|
result += Context.Insertable(light_Log).ExecuteCommand();
|
||||||
return result > 0;
|
return result > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,6 @@ namespace DOAN.ServiceCore
|
|||||||
CurrentPackageCount = currentPackageCount,
|
CurrentPackageCount = currentPackageCount,
|
||||||
AlarmThreshold = layerItem.AlarmNum
|
AlarmThreshold = layerItem.AlarmNum
|
||||||
};
|
};
|
||||||
|
|
||||||
string alarmMessage = System.Text.Json.JsonSerializer.Serialize(alarmData);
|
string alarmMessage = System.Text.Json.JsonSerializer.Serialize(alarmData);
|
||||||
await notificationHubContext.Clients.All.SendAsync("PBL_lack_alarm", alarmMessage);
|
await notificationHubContext.Clients.All.SendAsync("PBL_lack_alarm", alarmMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user