Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
2024-07-04 16:53:36 +08:00
25 changed files with 689 additions and 260 deletions

View File

@@ -26,6 +26,7 @@ using Microsoft.Extensions.Logging;
using NetTaste;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Npgsql;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Asn1.X509.Qualified;
using Qiniu.Util;
@@ -91,16 +92,16 @@ namespace Tnb.ProductionMgr
private readonly IPrdInstockService _prdInstockService;
private readonly ISqlSugarRepository<RedisReadConfig> _repository;
private ISqlSugarClient db_Scantimer;
private readonly ISqlSugarClient db_CheckGettimer;
private readonly ISqlSugarClient db_SSXcodetimer;
private readonly ISqlSugarClient db_BGWCarrySupplementtimer;
private readonly ISqlSugarClient db_YCLGLDPJInstocktimer;
private readonly ISqlSugarClient db_YCLWXDPJInstocktimer;
private ISqlSugarClient db_CheckGettimer;
private ISqlSugarClient db_SSXcodetimer;
private ISqlSugarClient db_BGWCarrySupplementtimer;
private ISqlSugarClient db_YCLGLDPJInstocktimer;
private ISqlSugarClient db_YCLWXDPJInstocktimer;
private ISqlSugarClient db_Floor2UpMachinecodetimer;
private readonly ISqlSugarClient db_Floor2timer送空托到上升降区;
private readonly ISqlSugarClient db_Floor2timer送满托到下升降区;
private readonly ISqlSugarClient db_Floor2timer移走上升降区未生成预任务且满托的料架;
private readonly ISqlSugarClient db_Floor2timer移走下升降区未生成预任务且空托的料架;
private ISqlSugarClient db_Floor2timer送空托到上升降区;
private ISqlSugarClient db_Floor2timer送满托到下升降区;
private ISqlSugarClient db_Floor2timer移走上升降区未生成预任务且满托的料架;
private ISqlSugarClient db_Floor2timer移走下升降区未生成预任务且空托的料架;
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
private readonly IUserManager _userManager;
private readonly IBillRullService _billRullService;
@@ -111,6 +112,14 @@ namespace Tnb.ProductionMgr
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>();
static ConnectionStringsOptions connectionOpts = App.GetConfig<ConnectionStringsOptions>("ConnectionStrings", true);
static ConnectionConfig cfg = new()
{
ConfigId = connectionOpts.ConfigId,
ConnectionString = connectionOpts.ConnectString,
DbType = SqlSugar.DbType.PostgreSQL,
IsAutoCloseConnection = true,
};
#endregion
#region
@@ -226,6 +235,12 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
}
}
}
catch(NpgsqlException ex)
{
Console.WriteLine("【CheckGet】" + ex.Message);
LoggerSSX.LogError(ex.ToString());
//db_CheckGettimer = new SqlSugarClient(cfg);
}
catch (Exception ex)
{
Console.WriteLine("【CheckGet】" + ex.Message);
@@ -950,19 +965,18 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
carryBindInput.carrystd_id = rack.carrystd_id;
carryBindInput.source_code = target.outbill;
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result bindResult = await _wmsCarryBindService.CarryBind(carryBindInput);
int row = await db_Floor2UpMachinecodetimer.Updateable<WmsCarryH>().SetColumns(r => r.carry_status == ((int)(EnumCarryStatus.)).ToString()).Where(r => r.id == target.rackid).ExecuteCommandAsync();
if (row == 0)
{
throw new Exception($"【上升降机】料架{target.rackcode}状态回写失败");
}
WarehouseMgr.Entities.Dto.Outputs.Result bindResult = await _wmsCarryBindService.CarryBind(carryBindInput, db_Floor2UpMachinecodetimer);
if (bindResult.code != JNPF.Common.Enums.HttpStatusCode.OK)
{
throw new Exception(bindResult.msg);
}
// 开始码垛
bool result_开始码垛 = await Floor2UpDownMachinecode_SetTag(MechanicalArmConsts., target.stackingposition.ToString());
LoggerFloor2UpDownMachine.LogInformation($@"【上升降机】码垛结果 {result_开始码垛}");
if (!result_开始码垛)
{
throw new Exception($@"【上升降机】码垛结果 {result_开始码垛}");
}
// 回写料箱条码、码垛计数
await db_Floor2UpMachinecodetimer.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
{
@@ -980,15 +994,25 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
LoggerFloor2UpDownMachine.LogInformation($@"【上升降机】回写转库单的剩余可绑定料架数量");
// 开始码垛
bool result_开始码垛 = await Floor2UpDownMachinecode_SetTag(MechanicalArmConsts., target.stackingposition.ToString());
LoggerFloor2UpDownMachine.LogInformation($@"【上升降机】码垛结果 {result_开始码垛}");
if (!result_开始码垛)
{
throw new Exception($@"【上升降机】码垛结果 {result_开始码垛}");
}
await db_Floor2UpMachinecodetimer.Ado.CommitTranAsync();
}
}
catch (Exception ex)
{
// 测试代码 无问题后期删
if (ex.Message.Contains("Connection is busy"))
if (ex.Message.Contains("Exception while reading from stream"))
{
db_Floor2UpMachinecodetimer = db_Floor2UpMachinecodetimer.CopyNew();
LoggerFloor2UpDownMachine.LogError("【测试】重置连接");
db_Floor2UpMachinecodetimer.Close();
db_Floor2UpMachinecodetimer = _repository.CopyNew();
}
LoggerFloor2UpDownMachine.LogError(ex.ToString());
@@ -1039,12 +1063,12 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
List<string> configs_upMachine = new List<string>();
if (await GetBoolTag("东面提升机输送线", $"上升降机请求送空托1"))
{
LoggerFloor2RackDelivery.LogError($"【送空托到上升降区】上升降机请求送空托1 true");
LoggerFloor2RackDelivery.LogInformation($"【送空托到上升降区】上升降机请求送空托1 true");
configs_upMachine.Add(floor2mechanicalAtmDic["上升降机请求送空托1"]);
}
if (await GetBoolTag("东面提升机输送线", $"上升降机请求送空托2"))
{
LoggerFloor2RackDelivery.LogError($"【送空托到上升降区】上升降机请求送空托2 true");
LoggerFloor2RackDelivery.LogInformation($"【送空托到上升降区】上升降机请求送空托2 true");
configs_upMachine.Add(floor2mechanicalAtmDic["上升降机请求送空托2"]);
}
@@ -1164,12 +1188,12 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
List<string> configs_upMachine = new List<string>();
if (await GetBoolTag("东面提升机输送线", $"下升降机请求送满托1"))
{
LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】下升降机请求送满托1 true");
LoggerFloor2RackDelivery.LogInformation($"【送满托到下升降区】下升降机请求送满托1 true");
configs_upMachine.Add(floor2mechanicalAtmDic["下升降机请求送满托1"]);
}
if (await GetBoolTag("东面提升机输送线", $"下升降机请求送满托2"))
{
LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】下升降机请求送满托2 true");
LoggerFloor2RackDelivery.LogInformation($"【送满托到下升降区】下升降机请求送满托2 true");
configs_upMachine.Add(floor2mechanicalAtmDic["下升降机请求送满托2"]);
}
@@ -1193,6 +1217,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
return;
}
await db_Floor2timer送满托到下升降区.Ado.BeginTranAsync();
// 料架区
foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHs)
@@ -1214,7 +1239,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
var item = r.FirstOrDefault();
// 空载具入库: 前面通过OrderBy(d => d.id)对WmsCarryCode_id进行了排序 那么如果第一行有数据则说明存在非空料箱
// 没有物料且没有退料标记的不满足出库条件
if (!string.IsNullOrEmpty(item.WmsCarryCode_id) && (item.wmsCarryH.need_return == 0 || item.wmsCarryH.need_return == null))
if (!string.IsNullOrEmpty(item.WmsCarryCode_id) && item.wmsCarryH.carry_status != ((int)(EnumCarryStatus.退)).ToString())
{
return new BasLocation();
}
@@ -1275,11 +1300,6 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
LoggerFloor2RackDelivery.LogInformation($"【送满托到下升降区】 开始生成预任务 起点{startLocation.location_code} 终点{wmsMechanicalArmH.location_code} 料架 {targetCarry.carry_code}");
await db_Floor2timer送满托到下升降区.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH
{
need_return = 0
}).Where(r => r.id == targetCarry.id).ExecuteCommandAsync();
bool result = await createPretask(startLocation.id, wmsMechanicalArmH.location_id, targetCarry.id, targetCarry.carry_code, LoggerFloor2RackDelivery, db_Floor2timer送满托到下升降区);
if (!result)
{
@@ -1329,12 +1349,12 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
List<string> configs_upMachine = new List<string>();
if (await GetBoolTag("东面提升机输送线", $"上升降机请求取满托1"))
{
LoggerFloor2RackDelivery.LogError($"【移走上升降区未生成预任务且满托的料架】上升降机请求取满托1 true");
LoggerFloor2RackDelivery.LogInformation($"【移走上升降区未生成预任务且满托的料架】上升降机请求取满托1 true");
configs_upMachine.Add(floor2mechanicalAtmDic["上升降机请求取满托1"]);
}
if (await GetBoolTag("东面提升机输送线", $"上升降机请求取满托2"))
{
LoggerFloor2RackDelivery.LogError($"【移走上升降区未生成预任务且满托的料架】上升降机请求取满托2 true");
LoggerFloor2RackDelivery.LogInformation($"【移走上升降区未生成预任务且满托的料架】上升降机请求取满托2 true");
configs_upMachine.Add(floor2mechanicalAtmDic["上升降机请求取满托2"]);
}
@@ -1435,13 +1455,13 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
List<string> configs_upMachine = new List<string>();
if (await GetBoolTag("东面提升机输送线", $"下升降机请求取空托1"))
{
LoggerFloor2RackDelivery.LogError($"【移走下升降区空托的料架】下升降机请求取空托1 true");
LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】下升降机请求取空托1 true");
configs_upMachine.Add(floor2mechanicalAtmDic["下升降机请求取空托1"]);
}
if (await GetBoolTag("东面提升机输送线", $"下升降机请求取空托2"))
{
LoggerFloor2RackDelivery.LogError($"【移走下升降区空托的料架】下升降机请求取空托2 true");
LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】下升降机请求取空托2 true");
configs_upMachine.Add(floor2mechanicalAtmDic["下升降机请求取空托2"]);
}
@@ -1455,13 +1475,13 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
//await db.BeginTranAsync();
// 读取下升降机的左右料架区配置
await db_Floor2timer移走下升降区未生成预任务且空托的料架.Ado.BeginTranAsync();
List<WmsMechanicalArmH> WmsMechanicalArmHs = db_Floor2timer移走下升降区未生成预任务且空托的料架.Queryable<WmsMechanicalArmH>().Where(r => !string.IsNullOrEmpty(r.rackcode) && r.iscreatepretask == 0 && configs_upMachine.Contains(r.name)).ToList();
foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHs)
{
LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 开始执行预任务生成 {wmsMechanicalArmH.location_code} {wmsMechanicalArmH.outbill} {wmsMechanicalArmH.barcodes}");
await db_Floor2timer移走下升降区未生成预任务且空托的料架.Ado.BeginTranAsync();
await db_Floor2timer移走下升降区未生成预任务且空托的料架.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
{
iscreatepretask = 1
@@ -1480,13 +1500,20 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
BasLocation endLocation = rackEndLocations.First();
int row = await db_Floor2timer移走下升降区未生成预任务且空托的料架.Updateable<WmsCarryH>().SetColumns(r => r.carry_status == "0").Where(r => r.id == wmsMechanicalArmH.rackid).ExecuteCommandAsync();
if (row == 0)
{
throw new Exception($"【移走下升降区空托的料架】料架{wmsMechanicalArmH.rackcode}状态回写失败");
}
// 解除绑定料箱到料架
CarryBindInput carryBindInput = new() { };
carryBindInput.carry_id = wmsMechanicalArmH.rackid;
carryBindInput.carry_code = wmsMechanicalArmH.rackcode;
carryBindInput.source_code = wmsMechanicalArmH.outbill;
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result unbindResult = await _wmsCarryUnbindService.CarryUnbind(carryBindInput);
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result unbindResult = await _wmsCarryUnbindService.CarryUnbind(carryBindInput, db_Floor2timer移走下升降区未生成预任务且空托的料架);
if (unbindResult.code != JNPF.Common.Enums.HttpStatusCode.OK)
{
throw new Exception(unbindResult.msg);
@@ -1506,8 +1533,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 未成功生成预任务 起点{wmsMechanicalArmH.location_code} 终点{endLocation.location_code} 料架 {wmsMechanicalArmH.rackcode}");
throw new Exception($"【移走下升降区空托的料架】 未成功生成预任务 起点{wmsMechanicalArmH.location_code} 终点{endLocation.location_code} 料架 {wmsMechanicalArmH.rackcode}");
}
await db_Floor2timer移走下升降区未生成预任务且空托的料架.Ado.CommitTranAsync();
}
await db_Floor2timer移走下升降区未生成预任务且空托的料架.Ado.CommitTranAsync();
}
}
catch (Exception ex)
@@ -1666,6 +1693,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
#endregion
#endregion
public Task StartAsync(CancellationToken cancellationToken)
@@ -1692,6 +1720,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
Floor2timer移走上升降区未生成预任务且满托的料架 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
Floor2timer移走下升降区未生成预任务且空托的料架 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
return Task.CompletedTask;
}