This commit is contained in:
qianjiawei
2024-01-29 15:55:11 +08:00
parent 0cbce7c9fd
commit 878a800bc7
6 changed files with 97 additions and 18 deletions

View File

@@ -121,8 +121,7 @@ namespace Tnb.ProductionMgr
private void CheckGet(object state) private void CheckGet(object state)
{ {
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>(); Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
getdic.Add("SSX-021-005", new string[] { "CS05", "FullBoxAllowGet", "Code" }); getdic.Add("SSX-021-005", new string[] { "YTCS", "AllowFullOut_CS05", "LiftCode" });
getdic.Add("SSX-021-006", new string[] { "CS06", "FullBoxAllowGet", "Code" });
foreach (var key in getdic.Keys) foreach (var key in getdic.Keys)
{ {
try try
@@ -138,14 +137,16 @@ namespace Tnb.ProductionMgr
JObject? coderes = JsonConvert.DeserializeObject<JObject>(codedata); JObject? coderes = JsonConvert.DeserializeObject<JObject>(codedata);
string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value<string>("Value")! : ""; string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value<string>("Value")! : "";
var DistaskH = _repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_code == coderesult && p.status == WmsWareHouseConst.TASK_BILL_STATUS_RUNING_ID).First(); var DistaskH = _repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_code == coderesult && p.status == WmsWareHouseConst.TASK_BILL_STATUS_RUNING_ID).First();
dynamic reqBody = new ExpandoObject(); if (DistaskH != null)
reqBody.taskCode = DistaskH.bill_code; {
reqBody.slotCode = key; dynamic reqBody = new ExpandoObject();
reqBody.containerCode = coderesult; reqBody.taskCode = DistaskH.bill_code;
CancellationTokenSource Ctu = new(); reqBody.slotCode = key;
//{"code":500,"msg":"成功!"} reqBody.containerCode = coderesult;
dynamic respBody = HttpClientHelper.PostStreamAsync("http://192.168.11.104:1880/wcs/notify/cargo", reqBody, Ctu.Token).Result; CancellationTokenSource Ctu = new();
Ctu.Dispose(); dynamic respBody = HttpClientHelper.PostStreamAsync("http://192.168.11.104:1880/wcs/notify/cargo", reqBody, Ctu.Token).Result;
Ctu.Dispose();
}
} }
} }
catch (Exception) catch (Exception)
@@ -190,7 +191,7 @@ namespace Tnb.ProductionMgr
public Task StartAsync(CancellationToken cancellationToken) 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(300)); CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
// Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(300)); // Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
return Task.CompletedTask; return Task.CompletedTask;
} }

View File

@@ -74,6 +74,7 @@ namespace Tnb.WarehouseMgr.Interfaces
/// <param name="ele"></param> /// <param name="ele"></param>
/// <returns></returns> /// <returns></returns>
Task<List<WmsPointH>> PathAlgorithmsEle(string pStartId, string pEndId, int ele); Task<List<WmsPointH>> PathAlgorithmsEle(string pStartId, string pEndId, int ele);
Task SsxControl(WmsDistaskH disTask, string action);
Func<string, int, Task> AddUnExecuteTask { get; set; } Func<string, int, Task> AddUnExecuteTask { get; set; }
} }
} }

View File

@@ -403,7 +403,7 @@ namespace Tnb.WarehouseMgr
{ {
_ = await _db.Deleteable(elevatorQueueItem).ExecuteCommandAsync(); _ = await _db.Deleteable(elevatorQueueItem).ExecuteCommandAsync();
} }
await _wareHouseService.SsxControl(disTask, "LOAD");
} }
else if (input.action == "UNLOAD") else if (input.action == "UNLOAD")
{ {
@@ -414,7 +414,7 @@ namespace Tnb.WarehouseMgr
}; };
Logger.Information($"taskCompleUpInput json parameter:{JsonConvert.SerializeObject(taskCompleUpInput)}"); Logger.Information($"taskCompleUpInput json parameter:{JsonConvert.SerializeObject(taskCompleUpInput)}");
await _wareHouseService.TaskComplate(taskCompleUpInput); await _wareHouseService.TaskComplate(taskCompleUpInput);
await _wareHouseService.SsxControl(disTask, "UNLOAD");
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@@ -57,6 +57,7 @@ namespace Tnb.WarehouseMgr
private static Dictionary<string, object> locMap = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); private static Dictionary<string, object> locMap = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
private readonly RedisData _redisData; private readonly RedisData _redisData;
public Func<string, int, Task> AddUnExecuteTask { get; set; } public Func<string, int, Task> AddUnExecuteTask { get; set; }
@@ -270,6 +271,80 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException("点位" + input.targetName + "不可放", 500); throw new AppFriendlyException("点位" + input.targetName + "不可放", 500);
} }
/// <summary>
/// 判断CTU是否可以取货
/// </summary>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public async Task<dynamic> CheckGet()
{
try
{
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
getdic.Add("SSX-021-005", new string[] { "YTCS", "AllowFullOut_CS05", "LiftCode" });
var strs = getdic.First().Value;
string data = await _redisData.GetHash(strs[0], strs[1]);
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
if (result)
{
string codedata = _redisData.GetHash(strs[0], strs[2]).Result;
JObject? coderes = JsonConvert.DeserializeObject<JObject>(codedata);
string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value<string>("Value")! : "";
return new { flag =true, code = coderesult };
}
else
{
return new { flag = false, code = "" };
}
}
catch (Exception ex)
{
throw new AppFriendlyException($"接口请求异常", 500);
}
}
public async Task SsxControl(WmsDistaskH disTask, string action)
{
Dictionary<string, string[]> putdic = new Dictionary<string, string[]>();
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
getdic.Add("SSX-021-005", new string[] { "YTCS", "AllowFullOut_CS05", "true" });
putdic.Add("SSX-021-006", new string[] { "YTCS", "", "" });
if (action == "LOAD")//取货
{
if (getdic.Keys.Contains(disTask.startlocation_code))
{
var strarr = getdic.Where(p => p.Key == disTask.startlocation_code).First().Value;
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = strarr[0],
["token"] = _eleCtlCfg.token,
["TagName"] = strarr[1],
["Value"] = strarr[2],
};
await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, pars: dicCommand);
}
}
else if (action == "UNLOAD")//放货
{
if (putdic.Keys.Contains(disTask.endlocation_code))
{
var strarr = putdic.Where(p => p.Key == disTask.endlocation_code).First().Value;
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = strarr[0],
["token"] = _eleCtlCfg.token,
["TagName"] = strarr[1],
["Value"] = strarr[2],
};
await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, pars: dicCommand);
}
}
}
/// <summary> /// <summary>
/// 生成任务执行 /// 生成任务执行
/// </summary> /// </summary>
@@ -1058,6 +1133,8 @@ namespace Tnb.WarehouseMgr
} }
await _db.Ado.CommitTranAsync(); await _db.Ado.CommitTranAsync();
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -2,14 +2,14 @@
"ConnectionStrings": { "ConnectionStrings": {
"ConfigId": "default", "ConfigId": "default",
"DBType": "PostgreSQL", //MySql;SqlServer;Oracle;PostgreSQL;Dm;Kdbndp;Sqlite; "DBType": "PostgreSQL", //MySql;SqlServer;Oracle;PostgreSQL;Dm;Kdbndp;Sqlite;
"Host": "localhost", "Host": "192.168.11.109",
"Port": "5432", "Port": "5432",
//"DBName": "tianyi_db", //"DBName": "tianyi_db",
//"UserName": "postgres", //"UserName": "postgres",
//"Password": "pass@word123", //"Password": "pass@word123",
"DBName": "tianyi_bas", "DBName": "tianyi",
"UserName": "totong", "UserName": "postgres",
"Password": "IPANyxGSKxIXg0dBM", "Password": "pass@word123",
//SqlServer //SqlServer
//"DefaultConnection": "server={0},{1};database={2};uid={3};pwd={4};MultipleActiveResultSets=true" //"DefaultConnection": "server={0},{1};database={2};uid={3};pwd={4};MultipleActiveResultSets=true"
//Kdbndp //Kdbndp

View File

@@ -62,7 +62,7 @@ public class Startup : AppStartup
services.AddSingleton<BackgroundService, TimedTaskBackgroundService>(sp => new TimedTaskBackgroundService()); services.AddSingleton<BackgroundService, TimedTaskBackgroundService>(sp => new TimedTaskBackgroundService());
//var bgSvc = App.GetRequiredService<BackgroundService>(); //var bgSvc = App.GetRequiredService<BackgroundService>();
//bgSvc.StartAsync(CancellationToken.None); //bgSvc.StartAsync(CancellationToken.None);
//services.AddHostedService<RedisBackGround>(); services.AddHostedService<RedisBackGround>();
} }