二楼自动下发中储仓任务
This commit is contained in:
@@ -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, "成功");
|
||||
|
||||
Reference in New Issue
Block a user