redis
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Tnb.Common.Redis;
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
using Tnb.ProductionMgr.Entities.Enums;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
@@ -11,25 +12,24 @@ namespace Tnb.ProductionMgr
|
||||
//redis定时获取数采数据
|
||||
public class RedisBackGround : IHostedService, IDisposable
|
||||
{
|
||||
private readonly Timer? packtimer;
|
||||
private readonly Timer? limittimer;
|
||||
private readonly RedisCache _redisCache;
|
||||
private Timer? ZSpacktimer;
|
||||
private Timer? JCpacktimer;
|
||||
private Timer? limittimer;
|
||||
private readonly RedisData _redisData;
|
||||
private readonly IPrdInstockService _prdInstockService;
|
||||
public RedisBackGround(RedisCache redisCache, IPrdInstockService prdInstockService)
|
||||
public RedisBackGround(RedisData redisData, IPrdInstockService prdInstockService)
|
||||
{
|
||||
_redisCache = redisCache;
|
||||
_redisData = redisData;
|
||||
_prdInstockService = prdInstockService;
|
||||
}
|
||||
//获取注塑装箱状态
|
||||
private void GetZSPackStatus(object state)
|
||||
{
|
||||
// Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
|
||||
// Console.WriteLine($"获取注塑装箱状态");
|
||||
string[] strs = new string[1] { "TY4C-ZHUSU1" };
|
||||
string sign = "agvMode";
|
||||
foreach (string s in strs)
|
||||
{
|
||||
Dictionary<string, string> dic = _redisCache.HGetAll(s).Result;
|
||||
Dictionary<string, string> dic = _redisData.HGetAll(s).Result;
|
||||
foreach (KeyValuePair<string, string> kv in dic)
|
||||
{
|
||||
if (!kv.Key.Contains(sign))
|
||||
@@ -40,7 +40,7 @@ namespace Tnb.ProductionMgr
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(kv.Value);
|
||||
if (res != null && res["Value"] != null)
|
||||
{
|
||||
if (int.Parse(res["Value"]!.ToString()) is not ((int)Eagvmode.无请求) or not ((int)Eagvmode.收到请求))
|
||||
if (int.Parse(res["Value"]!.ToString()) is not ((int)Eagvmode.无请求) and not ((int)Eagvmode.收到请求))
|
||||
{
|
||||
InstockInput instockInput = new()
|
||||
{
|
||||
@@ -55,13 +55,11 @@ namespace Tnb.ProductionMgr
|
||||
//获取挤出装箱状态
|
||||
private void GetJCPackStatus(object state)
|
||||
{
|
||||
// Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
|
||||
// Console.WriteLine($"获取挤出装箱状态");
|
||||
string[] strs = new string[1] { "TY4C-SHUSONG-JC" };
|
||||
string sign = "AGVFullCall";
|
||||
foreach (string s in strs)
|
||||
{
|
||||
Dictionary<string, string> dic = _redisCache.HGetAll(s).Result;
|
||||
Dictionary<string, string> dic = _redisData.HGetAll(s).Result;
|
||||
foreach (KeyValuePair<string, string> kv in dic)
|
||||
{
|
||||
if (!kv.Key.Contains(sign))
|
||||
@@ -87,13 +85,17 @@ namespace Tnb.ProductionMgr
|
||||
//获取限位状态
|
||||
private void GetLimitStatus(object state)
|
||||
{
|
||||
// Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
|
||||
// Console.WriteLine($"获取限位状态");
|
||||
/*
|
||||
Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
|
||||
Console.WriteLine($"获取挤出装箱状态");
|
||||
string data = _redisData.GetHash("TY4C-SHUSONG-JC", "AGVFullCall").Result;
|
||||
Console.WriteLine(data);*/
|
||||
/*
|
||||
string[] strs = new string[1] { "TY4C-WAIBAO" };
|
||||
string sign = "AGVCall";
|
||||
foreach (string s in strs)
|
||||
{
|
||||
Dictionary<string, string> dic = _redisCache.HGetAll(s).Result;
|
||||
Dictionary<string, string> dic = _redisData.HGetAll(s).Result;
|
||||
foreach (KeyValuePair<string, string> kv in dic)
|
||||
{
|
||||
if (!kv.Key.Contains(sign))
|
||||
@@ -110,17 +112,19 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
packtimer?.Dispose();
|
||||
ZSpacktimer?.Dispose();
|
||||
JCpacktimer?.Dispose();
|
||||
limittimer?.Dispose();
|
||||
}
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
// packtimer = new Timer(GetPackStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
// limittimer = new Timer(GetLimitStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
// ZSpacktimer = new Timer(GetZSPackStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
// JCpacktimer = new Timer(GetJCPackStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
// limittimer = new Timer(GetLimitStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
|
||||
Reference in New Issue
Block a user