PBL 1-15 审核修改

This commit is contained in:
2025-01-16 10:13:50 +08:00
parent ebfc811f99
commit 295f8c08ad
11 changed files with 417 additions and 74 deletions

View File

@@ -2,8 +2,10 @@
using DOAN.Model.PBL;
using DOAN.Model.PBL.Dto;
using DOAN.Service.PBL.IService;
using DOAN.ServiceCore.Signalr;
using Infrastructure.Attribute;
using Mapster;
using Microsoft.AspNetCore.SignalR;
using Newtonsoft.Json.Linq;
@@ -15,6 +17,11 @@ 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) {
notificationHubContext= _notificationHubContext;
}
public bool TestPLc(string address, PLCTool pLCTool)
{
bool isSucesss = pLCTool.ReadBit(address);
@@ -40,14 +47,14 @@ namespace DOAN.Service.PBL
// 2.根据总成零件号 ,版本 查询对应零件号,使得对应料架亮灯
// 同一个会有多个料架
//镜壳 料架
//镜壳 料架
List<Storagelocation> MirrorshellShelfList = Context.Queryable<Storagelocation>().Where(it => it.Partnumber ==
SqlFunc.Subqueryable<Billofmaterials>().Where(It => It.Productcode == light.AssemblyPartNumber && It.Version == light.Version).Select(it => it.MirrorshellCode)).ToList();
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)
if (MirrorshellShelfList != null && MirrorshellShelfList.Count() > 0)
{
foreach (var item1 in MirrorshellShelfList)
@@ -97,6 +104,11 @@ namespace DOAN.Service.PBL
}
else
{
// 发送socket 通知
string message=$"MES产品编号{light.AssemblyPartNumber}或者版本{light.Version},在PBL中找不到。请维护PBL料架信息";
notificationHubContext.Clients.All.SendAsync("PBL_bom_except", light);
return false;
}
@@ -121,7 +133,7 @@ namespace DOAN.Service.PBL
Context.Insertable(item).ExecuteCommand();
//2 找到对应的库存最大料架 灭灯
Storagelocation storagelocation = Context.Queryable<Storagelocation>().Where(it => it.Partnumber == 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)
{
@@ -132,14 +144,13 @@ namespace DOAN.Service.PBL
{
storagelocation.IsLight = 0;
// storagelocation.PackageNum -= 1;
if (storagelocation.PackageNum < 0)
{
storagelocation.PackageNum = 0;
}
//if (storagelocation.PackageNum < 0)
//{
// storagelocation.PackageNum = 0;
//}
//3 扣减对应的库存
// 合并货架的id
int[] ids = { 1, 2, 3, 4, 19, 20, 21, 22 };
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();