42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using JSMachine.WMS.Common.Cache.Model;
|
|
using JSMachine.WMS.Common.Cache;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.Caching.Memory;
|
|
using JSMachine.WMS.Netty.NettyAsClient.Command;
|
|
using JSMachine.WMS.Infrastructure.Helper;
|
|
|
|
namespace JSMachine.WMS.Netty.NettyAsClient.CommandHandler
|
|
{
|
|
public class BarCodeCmdHandlerL : BaseCmdhandler
|
|
{
|
|
public async override Task<bool> Handle(BaseCmd msg)
|
|
{
|
|
return await Task.Run(() =>
|
|
{
|
|
if (msg is BarCodeUploadCmd barCodeUploadCmd)
|
|
{
|
|
GlobalMemoryCache.AddCach(
|
|
RemoteIPInfo.IP,
|
|
new BarCodeInfo
|
|
{
|
|
AddTime = DateTime.Now,
|
|
BarCode = barCodeUploadCmd.Msg,
|
|
IP = RemoteIPInfo.IP
|
|
},
|
|
new MemoryCacheEntryOptions
|
|
{
|
|
AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(30),
|
|
});
|
|
|
|
LogHelper.Info($"收到条码信息({RemoteIPInfo.IP}): 【{barCodeUploadCmd.Msg}】");
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
});
|
|
}
|
|
}
|
|
}
|