This commit is contained in:
qianjiawei
2024-03-08 17:54:08 +08:00
parent a5c60fb131
commit f37ad2bfa3
9 changed files with 224 additions and 61 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Data;
using System.Dynamic;
using System.Security.Policy;
using Aop.Api.Domain;
@@ -33,6 +34,7 @@ namespace Tnb.ProductionMgr
private Timer? Readtimer;
private Timer? CheckGettimer;
private Timer? Scantimer;
private Timer? SSXcodetimer;
private readonly RedisData _redisData;
private readonly IPrdInstockService _prdInstockService;
private readonly ISqlSugarRepository<RedisReadConfig> _repository;
@@ -126,6 +128,11 @@ namespace Tnb.ProductionMgr
{
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
getdic.Add("SSX-021-005", new string[] { "YTCS", "AllowFullOut_CS05", "LiftCode" });
getdic.Add("SSX-011-002", new string[] { "YTCS", "AllowAgvFullIn_CS02", "Code_CS02" });
getdic.Add("SSX-011-004", new string[] { "YTCS", "AllowCtuFullOut_CS04", "Code_CS04" });
getdic.Add("SSX-111-011", new string[] { "东面提升机输送线", "下升降机11允许出箱", "下升降机11条码" });
getdic.Add("SSX-111-012", new string[] { "东面提升机输送线", "下升降机12允许出箱", "下升降机12条码" });
foreach (var key in getdic.Keys)
{
try
@@ -141,7 +148,7 @@ namespace Tnb.ProductionMgr
JObject? coderes = JsonConvert.DeserializeObject<JObject>(codedata);
string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value<string>("Value")! : "";
coderesult = coderesult.Replace("\r", "");
var DistaskH = _repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_code == coderesult && p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID).First();
var DistaskH = _repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_code == coderesult && p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID&&string.IsNullOrEmpty(p.extras)).First();
if (DistaskH != null)
{
dynamic reqBody = new ExpandoObject();
@@ -150,6 +157,8 @@ namespace Tnb.ProductionMgr
reqBody.containerCode = coderesult;
CancellationTokenSource Ctu = new();
dynamic respBody = HttpClientHelper.PostStreamAsync("http://192.168.11.104:1880/wcs/notify/cargo", reqBody, Ctu.Token).Result;
DistaskH.extras = respBody;
_repository.AsSugarClient().Updateable(DistaskH).ExecuteCommand();
Ctu.Dispose();
}
}
@@ -165,6 +174,7 @@ namespace Tnb.ProductionMgr
{
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
getdic.Add("BGWRKYCL02", new string[] { "CP8", "AllowGetFullBox1", "code1", "PutDoneEmptyBox","false" });
getdic.Add("BGWRKYCL01", new string[] { "CP8", "AllowGetFullBox2", "code2", "PutDoneEmptyBox", "false" });
foreach (var key in getdic.Keys)
{
try
@@ -183,7 +193,7 @@ namespace Tnb.ProductionMgr
["TagName"] = strs[3],
["Value"] = strs[4],
};
HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, new Dictionary<string, string>(), dicCommand).Wait();
HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand).Wait();
string codedata = _redisData.GetHash(strs[0], strs[2]).Result;
@@ -192,7 +202,7 @@ namespace Tnb.ProductionMgr
WmsCarryH? carry = _repository.AsSugarClient().Queryable<WmsCarryH>().Single(it => it.carry_code == coderesult);
if (carry != null)
{
if (_repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_id == carry.id && (p.status == WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID || p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID || p.status == WmsWareHouseConst.TASK_BILL_STATUS_RUNING_ID)).Any())
if (_repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_id == carry.id && p.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID ).Any())
continue;
var WmsCarryCode = _repository.AsSugarClient().Queryable<WmsCarryCode>().Single(it => it.carry_id == carry.id);
if (WmsCarryCode != null)
@@ -220,24 +230,73 @@ namespace Tnb.ProductionMgr
}
}
}
private void SSXcode(object state)
{
Dictionary<string, string[]> dic = new Dictionary<string, string[]>();
dic.Add("东面提升机输送线", new string[] { "下升降机判断请求", "下升降机判断条码", "下升降机判断完毕", "下升降机判断结果" });
Dictionary<string, int> putdic = new Dictionary<string, int>();
putdic.Add("SSX-111-011", 11);
putdic.Add("SSX-111-012", 12);
foreach (var key in dic.Keys)
{
try
{
var strs = dic.Where(p => p.Key == key).First().Value;
string dataflag = _redisData.GetHash(key, strs[0]).Result;
JObject? resflag = JsonConvert.DeserializeObject<JObject>(dataflag);
bool re = resflag != null && resflag["Value"] != null ? resflag.Value<bool>("Value") : false;
if (!re)
continue;
string data = _redisData.GetHash(key, strs[1]).Result;
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
string? result = res != null && res["Value"] != null ? res.Value<string>("Value") : "";
if (!string.IsNullOrEmpty(result))
{
result = result.Replace("\r", "");
var DistaskH = _repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_code == result && p.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).OrderByDescending(p => p.create_time).First();
if (DistaskH != null)
{
Dictionary<string, string> dicCommand2 = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = strs[0],
["token"] = _eleCtlCfg.token,
["TagName"] = strs[3],
["Value"] = putdic.Keys.Contains(DistaskH.startlocation_code) ? putdic.Where(p => p.Key == DistaskH.startlocation_code).First().Value.ToString() : "13",
};
HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2).Wait();
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = strs[0],
["token"] = _eleCtlCfg.token,
["TagName"] = strs[2],
["Value"] = "true",
};
HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand).Wait();
}
}
}
catch (Exception)
{
}
}
}
public void Dispose()
{
Readtimer?.Dispose();
CheckGettimer?.Dispose();
Scantimer?.Dispose();
SSXcodetimer?.Dispose();
}
public Task StartAsync(CancellationToken cancellationToken)
{
// Readtimer = new Timer(GetRedisData, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
Readtimer = new Timer(GetRedisData, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(20));
Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
SSXcodetimer= new Timer(SSXcode, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)