二楼自动下发中储仓任务
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Dynamic;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells.Charts;
|
||||
using JNPF;
|
||||
using JNPF.Common.Cache;
|
||||
using JNPF.Common.Core.Manager;
|
||||
@@ -36,6 +37,7 @@ using Tnb.ProductionMgr.Interfaces;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Configs;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
@@ -441,7 +443,6 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
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);
|
||||
@@ -846,13 +847,24 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
{
|
||||
throw new Exception($@"【送满托到下升降区】设定升降机满托{wmsMechanicalArmH.stackingposition}满托数量为 {LXCount} 结果为 {result}");
|
||||
}
|
||||
|
||||
// 绑定料架
|
||||
await db.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
|
||||
{
|
||||
mechanicalconfirm = 1,
|
||||
maxnum = LXCount
|
||||
}).Where(r => r.id == wmsMechanicalArmH.id).ExecuteCommandAsync();
|
||||
|
||||
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱开始生成预任务");
|
||||
bool pretask_result = await _wareHouseService.Floor2EmptyCarryCreateZZCPretask(wmsMechanicalArmH.rackid);
|
||||
if (pretask_result)
|
||||
{
|
||||
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱生成预任务完成");
|
||||
}
|
||||
else
|
||||
{
|
||||
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱生成预任务失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -869,10 +881,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
{
|
||||
string[] configs_upMachine = new string[2] { "二楼上升降机机械臂左", "二楼上升降机机械臂右" };
|
||||
|
||||
// 找到没有绑定料架的且点位未锁定的料架区
|
||||
// 找到没有绑定料架的且库位未锁定的料架区
|
||||
ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHsuagar = _repository.AsSugarClient().Queryable<WmsMechanicalArmH>().
|
||||
InnerJoin<WmsPointH>((a, b) => a.point_id == b.id)
|
||||
.Where((a, b) => string.IsNullOrEmpty(a.rackcode) && b.is_lock == 0 && configs_upMachine.Contains(a.name));
|
||||
.InnerJoin<BasLocation>((a, b, c) => b.location_id == c.id)
|
||||
.Where((a, b, c) => string.IsNullOrEmpty(a.rackcode) && c.is_lock == 0 && configs_upMachine.Contains(a.name));
|
||||
|
||||
List<WmsMechanicalArmH> WmsMechanicalArmHs = WmsMechanicalArmHsuagar.ToList();
|
||||
|
||||
@@ -944,10 +957,14 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
{
|
||||
is_lock = 1
|
||||
}).Where(r => r.id == startLocation.id).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Updateable<WmsPointH>().SetColumns(r => new WmsPointH
|
||||
await _repository.AsSugarClient().Updateable<BasLocation>().SetColumns(r => new BasLocation
|
||||
{
|
||||
is_lock = 1
|
||||
}).Where(r => r.id == endPoint.id).ExecuteCommandAsync();
|
||||
}).Where(r => r.id == endPoint.location_id).ExecuteCommandAsync();
|
||||
//await _repository.AsSugarClient().Updateable<WmsPointH>().SetColumns(r => new WmsPointH
|
||||
//{
|
||||
// is_lock = 1
|
||||
//}).Where(r => r.id == endPoint.id).ExecuteCommandAsync();
|
||||
|
||||
|
||||
LoggerFloor2RackDelivery.LogInformation($"【送空托到上升降区】 开始生成预任务 起点{startPoint.point_code} 终点{endPoint.point_code} 料架 {targetCarry.carry_code}");
|
||||
@@ -979,13 +996,14 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
// 找到没有绑定料架的且点位未锁定的料架区
|
||||
ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHsuagar = _repository.AsSugarClient().Queryable<WmsMechanicalArmH>().
|
||||
InnerJoin<WmsPointH>((a, b) => a.point_id == b.id)
|
||||
.Where((a, b) => string.IsNullOrEmpty(a.rackcode) && b.is_lock == 0 && configs_upMachine.Contains(a.name));
|
||||
.InnerJoin<BasLocation>((a, b, c) => b.location_id == c.id)
|
||||
.Where((a, b, c) => string.IsNullOrEmpty(a.rackcode) && c.is_lock == 0 && configs_upMachine.Contains(a.name));
|
||||
|
||||
List<WmsMechanicalArmH> WmsMechanicalArmHs = WmsMechanicalArmHsuagar.ToList();
|
||||
|
||||
if (WmsMechanicalArmHs.Count() == 0)
|
||||
{
|
||||
//LoggerFloor2RackDelivery.LogWarning($"【送满托到下升降区】 无需补充料架区 {WmsMechanicalArmHsuagar.ToSqlString()}");
|
||||
LoggerFloor2RackDelivery.LogWarning($"【送满托到下升降区】 无需补充料架区 {WmsMechanicalArmHsuagar.ToSqlString()}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1072,8 +1090,6 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
// 满料架
|
||||
WmsCarryH targetCarry = wmsCarryHs[0];
|
||||
|
||||
|
||||
|
||||
WmsPointH startPoint = startPoints.First();
|
||||
WmsPointH endPoint = endPoints.First();
|
||||
|
||||
@@ -1081,10 +1097,15 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
{
|
||||
is_lock = 1
|
||||
}).Where(r => r.id == startLocation.id).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Updateable<WmsPointH>().SetColumns(r => new WmsPointH
|
||||
|
||||
await _repository.AsSugarClient().Updateable<BasLocation>().SetColumns(r => new BasLocation
|
||||
{
|
||||
is_lock = 1
|
||||
}).Where(r => r.id == endPoint.id).ExecuteCommandAsync();
|
||||
}).Where(r => r.id == endPoint.location_id).ExecuteCommandAsync();
|
||||
//await _repository.AsSugarClient().Updateable<WmsPointH>().SetColumns(r => new WmsPointH
|
||||
//{
|
||||
// is_lock = 1
|
||||
//}).Where(r => r.id == endPoint.id).ExecuteCommandAsync();
|
||||
|
||||
|
||||
LoggerFloor2RackDelivery.LogInformation($"【送满托到下升降区】 开始生成预任务 起点{startPoint.point_code} 终点{endPoint.point_code} 料架 {targetCarry.carry_code}");
|
||||
@@ -1177,10 +1198,10 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
{
|
||||
is_lock = 1
|
||||
}).Where(r => r.id == endLocation.id).ExecuteCommandAsync();
|
||||
await db.Updateable<WmsPointH>(r => new WmsPointH
|
||||
{
|
||||
is_lock = 1
|
||||
}).Where(r => r.id == endPoint.id).ExecuteCommandAsync();
|
||||
//await db.Updateable<WmsPointH>(r => new WmsPointH
|
||||
//{
|
||||
// is_lock = 1
|
||||
//}).Where(r => r.id == endPoint.id).ExecuteCommandAsync();
|
||||
|
||||
LoggerFloor2RackDelivery.LogInformation($"【移走上升降区满托的料架】 开始执行预任务生成: 料架区为{wmsMechanicalArmH.name}{wmsMechanicalArmH.stackingposition} 料架为{wmsMechanicalArmH.rackcode}");
|
||||
|
||||
@@ -1290,10 +1311,10 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
{
|
||||
is_lock = 1
|
||||
}).Where(r => r.id == endLocation.id).ExecuteCommandAsync();
|
||||
await db.Updateable<WmsPointH>(r => new WmsPointH
|
||||
{
|
||||
is_lock = 1
|
||||
}).Where(r => r.id == endPoint.id).ExecuteCommandAsync();
|
||||
//await db.Updateable<WmsPointH>(r => new WmsPointH
|
||||
//{
|
||||
// is_lock = 1
|
||||
//}).Where(r => r.id == endPoint.id).ExecuteCommandAsync();
|
||||
|
||||
LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 开始执行预任务生成: 料架区为{wmsMechanicalArmH.name}{wmsMechanicalArmH.stackingposition} 料架为{wmsMechanicalArmH.rackcode}");
|
||||
|
||||
|
||||
@@ -314,5 +314,13 @@
|
||||
/// 分拣任务生成Encode
|
||||
/// </summary>
|
||||
public const string WMS_SORTINGTASK_ENCODE = "Sortingtask";
|
||||
/// <summary>
|
||||
/// 一楼中储仓出库工位
|
||||
/// </summary>
|
||||
public const string ZZCSSX111011 = "32609244599317";
|
||||
/// <summary>
|
||||
/// 一楼中储仓出库工位
|
||||
/// </summary>
|
||||
public const string ZZCSSX111012 = "32609251845653";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,5 +97,12 @@ namespace Tnb.WarehouseMgr.Interfaces
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<bool> Floor2MechanicalComplete(WmsDistaskH disTask, string action);
|
||||
|
||||
/// <summary>
|
||||
/// 二楼kiva把料架送到下升降机后生成中储仓入库任务
|
||||
/// </summary>
|
||||
/// <param name="rackid">料架id</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Floor2EmptyCarryCreateZZCPretask(string rackid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,8 @@ namespace Tnb.WarehouseMgr
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly RedisData _redisData;
|
||||
|
||||
public static SemaphoreSlim s_floor2CreatePretask = new(1);
|
||||
|
||||
public Func<string, int, Task> AddUnExecuteTask { get; set; }
|
||||
|
||||
|
||||
@@ -1628,6 +1630,10 @@ namespace Tnb.WarehouseMgr
|
||||
//更新电梯任务数量
|
||||
_ = await _db.Updateable<WmsElevatorH>().SetColumns(it => new WmsElevatorH { task_nums = it.task_nums - 1}).Where(it => disTasks.Select(x => x.area_code).Contains(it.area_code)).ExecuteCommandAsync();
|
||||
|
||||
// 更新中储仓任务数量
|
||||
_ = await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { task_nums = it.task_nums - 1 }).Where(it => disTasks.Where(r => r.startlocation_code.Contains("SSX-111-011") || r.startlocation_code.Contains("SSX-111-012")).Select(x => x.startlocation_code).Contains(it.location_code)).ExecuteCommandAsync();
|
||||
|
||||
|
||||
//更新载具,锁定状态为未锁定,更新载具的库位当前任务的目标库位
|
||||
|
||||
List<(string carry_id, string carry_status, string endlocation_id, string endlocation_code)> multiList = disTasks.Select(it => (it.carry_id, it.carry_status, it.endlocation_id, it.endlocation_code)).ToList();
|
||||
@@ -1694,6 +1700,7 @@ namespace Tnb.WarehouseMgr
|
||||
await _wmsCarryBindService.CarryCodeUnbind(carryCodeUnbindInput);
|
||||
}
|
||||
}
|
||||
// 成品调拨入库
|
||||
else if (dt.biz_type == WmsWareHouseConst.BIZTYPE_WMSTRANSFERINSTOCK_ID)
|
||||
{
|
||||
if (dt.start_floor == 3 && dt.end_floor == 3)
|
||||
@@ -2205,6 +2212,142 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 二楼kiva把料架送到下升降机后生成中储仓入库任务
|
||||
/// </summary>
|
||||
/// <param name="rackid">料架id</param>
|
||||
/// <returns></returns>
|
||||
|
||||
public async Task<bool> Floor2EmptyCarryCreateZZCPretask(string rackid)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<WmsCarryD> wmsCarryCodes = _db.Queryable<WmsCarryD>().Where(r => r.carry_id == rackid).ToList();
|
||||
|
||||
foreach (WmsCarryD wmsCarryD in wmsCarryCodes)
|
||||
{
|
||||
await s_floor2CreatePretask.WaitAsync();
|
||||
//入库取终点 //出库起点
|
||||
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID, Size = 1 };
|
||||
List<BasLocation> endLocations = await InStockStrategy(inStockStrategyInput);
|
||||
if (endLocations.Count == 0)
|
||||
{
|
||||
Logger.LogWarning("没有可用的入库库位");
|
||||
continue;
|
||||
}
|
||||
WmsPointH sPoint = null!;
|
||||
WmsPointH ePoint = null!;
|
||||
|
||||
BasLocation basLocation011 = _db.Queryable<BasLocation>().Where(r => r.id == WmsWareHouseConst.ZZCSSX111011).First();
|
||||
BasLocation basLocation012 = _db.Queryable<BasLocation>().Where(r => r.id == WmsWareHouseConst.ZZCSSX111012).First();
|
||||
|
||||
BasLocation startLocation = basLocation011.task_nums >= basLocation012.task_nums ? basLocation012 : basLocation011;
|
||||
|
||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == startLocation.id);
|
||||
if (endLocations?.Count > 0)
|
||||
{
|
||||
WmsCarryH carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == wmsCarryD.membercarry_code);
|
||||
//if (carry.carry_status == "1")
|
||||
//{
|
||||
// throw new AppFriendlyException("载具已占用!", 500);
|
||||
//}
|
||||
//if (carry.is_lock == 1)
|
||||
//{
|
||||
// throw new AppFriendlyException("载具已锁定!", 500);
|
||||
//}
|
||||
BasLocation loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||
bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
|
||||
if (!isMatch)
|
||||
{
|
||||
Logger.LogWarning("库位与载具规格不匹配");
|
||||
continue;
|
||||
}
|
||||
|
||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogWarning($"库位{endLocations[0].location_code}未在点位表中维护对应点位");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Logger.LogInformation($"【送满托到下升降区】 开始生成一楼CTU'预任务 起点{sPoint.point_code} 终点{ePoint.point_code} 料箱 {wmsCarryD.membercarry_code}");
|
||||
List<WmsPointH> points = new List<WmsPointH>();
|
||||
points.Add(sPoint);
|
||||
points.Add(ePoint);
|
||||
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
WmsPretaskH preTask = null;
|
||||
string bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
|
||||
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||
{
|
||||
WmsPointH? sPoint = it.FirstOrDefault();
|
||||
WmsPointH? ePoint = it.LastOrDefault();
|
||||
|
||||
preTask = new()
|
||||
{
|
||||
org_id = "",
|
||||
startlocation_id = sPoint?.location_id!,
|
||||
startlocation_code = sPoint?.location_code!,
|
||||
endlocation_id = ePoint?.location_id!,
|
||||
endlocation_code = ePoint?.location_code!,
|
||||
start_floor = sPoint?.floor.ToString(),
|
||||
end_floor = ePoint?.floor.ToString(),
|
||||
startpoint_id = sPoint?.id!,
|
||||
startpoint_code = sPoint?.point_code!,
|
||||
endpoint_id = ePoint?.id!,
|
||||
endpoint_code = ePoint?.point_code!,
|
||||
bill_code = bill_code,
|
||||
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID,
|
||||
task_type = "",
|
||||
carry_id = wmsCarryD.membercarry_id,
|
||||
carry_code = wmsCarryD.membercarry_code,
|
||||
area_id = sPoint?.area_id!,
|
||||
area_code = it.Key,
|
||||
require_id = "",
|
||||
require_code = "",
|
||||
create_id = "",
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
|
||||
return preTask;
|
||||
}).ToList();
|
||||
//更新页面
|
||||
//赋值签收状态
|
||||
|
||||
Logger.LogInformation($"开始执行 GenPreTask {JsonConvert.SerializeObject(preTasks)}");
|
||||
bool result = await GenPreTask(preTasks, null!);
|
||||
Logger.LogInformation($"GenPreTask 结果 {result}");
|
||||
if (result)
|
||||
{
|
||||
_ = await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_lock = 1 }).Where(r => r.id == endLocations[0].id).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { task_nums = it.task_nums + 1 }).Where(r => r.id == startLocation.id).ExecuteCommandAsync();
|
||||
Logger.LogInformation($"成功生成预任务:{preTasks.First().bill_code}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation($"【二楼kiva把料架送到下升降机后生成中储仓入库任务】 未成功生成预任务 起点{sPoint.point_code} 终点{ePoint.point_code} 料箱 {wmsCarryD.membercarry_code}");
|
||||
}
|
||||
s_floor2CreatePretask.Release();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Logger.LogInformation($"【二楼kiva把料架送到下升降机后生成中储仓入库任务】:{ex}");
|
||||
s_floor2CreatePretask.Release();
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_floor2CreatePretask.Release();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ namespace Tnb.WarehouseMgr
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -389,7 +389,7 @@ namespace Tnb.WarehouseMgr
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
|
||||
@@ -325,7 +325,7 @@ namespace Tnb.WarehouseMgr
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -379,7 +379,7 @@ namespace Tnb.WarehouseMgr
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
"ConnectionStrings": {
|
||||
"ConfigId": "default",
|
||||
"DBType": "PostgreSQL", //MySql;SqlServer;Oracle;PostgreSQL;Dm;Kdbndp;Sqlite;
|
||||
//"Host": "192.168.11.109",
|
||||
"Host": "127.0.0.1",
|
||||
"Host": "192.168.11.109",
|
||||
//"Host": "127.0.0.1",
|
||||
"Port": "5432",
|
||||
//"DBName": "tianyi_db",
|
||||
//"UserName": "postgres",
|
||||
|
||||
Reference in New Issue
Block a user