redis
This commit is contained in:
@@ -5,6 +5,7 @@ using JNPF.FriendlyException;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Tnb.Common.Redis;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
@@ -16,11 +17,10 @@ namespace Tnb.ProductionMgr
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class RedisDataService : IRedisDataService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly RedisCache _redisCache;
|
||||
public RedisDataService(RedisCache redisCache)
|
||||
private readonly RedisData _redisData;
|
||||
public RedisDataService(RedisData redisData)
|
||||
{
|
||||
_redisCache = redisCache;
|
||||
|
||||
_redisData = redisData;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据机号获取重量
|
||||
@@ -28,31 +28,13 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetWeight(string device, string jihao)
|
||||
{
|
||||
bool flag = await _redisCache.HashExist(device, jihao);
|
||||
bool flag = await _redisData.HashExist(device, jihao);
|
||||
if (!flag)
|
||||
{
|
||||
throw Oops.Bah("没有找到" + device + "----" + jihao + "的数据");
|
||||
}
|
||||
|
||||
string data = await _redisCache.GetHash(device, jihao);
|
||||
string data = await _redisData.GetHash(device, jihao);
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
|
||||
/*
|
||||
var dic =await _redisCache.HGetAll("TY4C-JICHU");
|
||||
string a = "";
|
||||
foreach (var kvp in dic)
|
||||
{
|
||||
a += kvp.Key + "&" + kvp.Value + "$";
|
||||
}
|
||||
|
||||
|
||||
string aa = "";
|
||||
var ss= aa.Split('$', StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach (var s in ss)
|
||||
{
|
||||
var b = s.Split('&');
|
||||
await _redisCache.HSet("TY4C-JICHU", b[0], b[1]);
|
||||
}*/
|
||||
|
||||
decimal result = res != null && res["Value"] != null ? decimal.Parse(res["Value"]!.ToString()) : throw Oops.Bah("数据格式错误");
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user