1.增加手动自检功能,主页增加状态显示

This commit is contained in:
hehaibing-1996
2024-06-11 14:03:06 +08:00
parent a87a93ea11
commit 95437c2ccf
24 changed files with 576 additions and 123 deletions

View File

@ -7,6 +7,7 @@ using WCS.BLL.Manager;
using WCS.BLL.Services.IService;
using WCS.Model;
using WCS.Model.ApiModel.SelfCheck;
using WCS.Model.WebSocketModel;
namespace WCS.BLL.Services.Service
{
@ -42,5 +43,76 @@ namespace WCS.BLL.Services.Service
Message = $"货架{string.Join(",", request.ShelfCodes)}已开始自检!",
};
}
public async Task<ResponseBase> StartSelfCheckByGroupName(List<string> GroupNames)
{
if (GroupNames == null || GroupNames.Count == 0)
{
return new ResponseCommon()
{
Code = 201,
Message = $"参数为空!",
};
}
//获取货架
var shelfs = ShelfManager.Shelves
.Where(t => GroupNames.Contains(t.GroupName))
.ToList();
var cleintIps = shelfs.Select(t => t.ClientIp).Distinct().ToList();
foreach (var ip in cleintIps)
{
var currentIdShelfs = shelfs.Where(t => t.ClientIp == ip)
.ToList();
Task.Run(() =>
{
foreach(var shelf in currentIdShelfs)
{
Task.Run(() =>
{
var warningModel = new WebSocketMessageModel()
{
IsWarning = false,
ClientIsReceived = true,
WarningType = WarningTypeEnum.,
StoreId = 0,
StoreCode = "",
ShelfCode = shelf.ShelfCode,
ShelfId = shelf.ShelfId,
ClientIp = shelf.WebSocketIpAddress,
WarningMessage = $"货架【{shelf.ShelfCode}】开始自检"
};
WarningManager.SendWarning(warningModel);
});
shelf.ShelfCheck();
Task.Run(() =>
{
var warningModel = new WebSocketMessageModel()
{
IsWarning = false,
ClientIsReceived = true,
WarningType = WarningTypeEnum.,
StoreId = 0,
StoreCode = "",
ShelfCode = shelf.ShelfCode,
ShelfId = shelf.ShelfId,
ClientIp = shelf.WebSocketIpAddress,
WarningMessage = $"货架【{shelf.ShelfCode}】已完成自检"
};
WarningManager.SendWarning(warningModel);
});
Thread.Sleep(10);
}
});
}
return new ResponseCommon()
{
Code = 200,
Message = $"已成功开始自检!",
};
}
}
}