三楼人工库逻辑等
This commit is contained in:
@@ -58,13 +58,11 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
private async Task<dynamic> PDAWmsEmptyOut(VisualDevModelDataCrInput input)
|
||||
{
|
||||
|
||||
if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_ZC_ID)
|
||||
await _s_taskExecuteSemaphore_F1ZCCOutstock.WaitAsync();
|
||||
else if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_HCC_ID)
|
||||
await _s_taskExecuteSemaphore_F2HCCOutstock.WaitAsync();
|
||||
SemaphoreSlim semaphoreSlim = null;
|
||||
try
|
||||
{
|
||||
semaphoreSlim = _wareHouseService.GetSemaphore("outstock", input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString());
|
||||
await semaphoreSlim.WaitAsync();
|
||||
Logger.Information("开始PDA空载具出库");
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
@@ -74,10 +72,15 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
//出库取起点,获取所有符合输入的载具规格的载具
|
||||
WmsEmptyOutstockH setQty = await _db.Queryable<WmsEmptyOutstockH>().FirstAsync(it => it.bill_code == input.data[nameof(WmsEmptyOutstockH.bill_code)].ToString());
|
||||
List<WmsCarryH>? carrys = await _db.Queryable<WmsCarryH>().LeftJoin<BasLocation>((a, b) => a.location_id == b.id)
|
||||
.Where((a, b) => a.carrystd_id == input.data[nameof(WmsEmptyOutstockH.carrystd_id)].ToString()
|
||||
&& a.carry_status == ((int)EnumCarryStatus.空闲).ToString() && a.is_lock == 0 && b.is_lock == 0 && b.is_type == ((int)EnumLocationType.存储库位).ToString())
|
||||
.ToListAsync();
|
||||
//出库取起点,获取所有符合输入的载具规格的载具
|
||||
OutStockStrategyQuery OutStockStrategyInput = new()
|
||||
{
|
||||
carrystd_id = input.data[nameof(OutStockStrategyQuery.carrystd_id)].ToString(),
|
||||
warehouse_id = input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString(),
|
||||
Size = 1
|
||||
};
|
||||
List<WmsCarryH>? carrys = await _wareHouseService.OutStockStrategy(OutStockStrategyInput);
|
||||
Logger.Information($"根据出库策略获取的载具数量:{carrys?.Count}");
|
||||
|
||||
WmsPointH sPoint = null!;
|
||||
WmsPointH ePoint = null!;
|
||||
@@ -90,139 +93,134 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
Logger.Information($"PDA空载具出库实际可出载具数量:{carrys.Count}");
|
||||
|
||||
if (int.Parse(input.data["qty"].ToString())> carrys.Count)
|
||||
if (carrys.Count < 1)
|
||||
{
|
||||
throw new AppFriendlyException($"实际可出空载具数量只有 {carrys.Count}", 500);
|
||||
throw new AppFriendlyException($"没有可以出库的空载具", 500);
|
||||
}
|
||||
|
||||
//根据每个载具的起始库位做路径运算
|
||||
for (i = 0; i < int.Parse(input.data["qty"].ToString()); i++)
|
||||
|
||||
if (carrys?.Count > 0)
|
||||
{
|
||||
|
||||
if (carrys?.Count > 0)
|
||||
{
|
||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carrys[i].location_id);
|
||||
}
|
||||
|
||||
if (sPoint != null && ePoint != null)
|
||||
{
|
||||
List<WmsPointH> points = new List<WmsPointH>();
|
||||
if (sPoint.area_code != ePoint.area_code)
|
||||
{
|
||||
points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
if (points.Count <= 2)
|
||||
{
|
||||
throw new AppFriendlyException($"sPoint {sPoint.point_code} ePoint{ePoint.point_code}该路径不存在", 500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points.Add(sPoint);
|
||||
points.Add(ePoint);
|
||||
}
|
||||
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTKPDA_ID, true);
|
||||
await _runService.Create(templateEntity, input);
|
||||
|
||||
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();
|
||||
//生成预任务
|
||||
WmsPretaskH preTask = new()
|
||||
{
|
||||
org_id = _userManager.User.OrganizeId,
|
||||
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 = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
||||
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
|
||||
task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID,
|
||||
carry_id = carrys![i].id,
|
||||
carry_code = carrys![i].carry_code,
|
||||
area_id = sPoint?.area_id!,
|
||||
area_code = it.Key,
|
||||
require_id = input.data["ReturnIdentity"].ToString()
|
||||
};
|
||||
preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!;
|
||||
preTask.create_id = _userManager.UserId;
|
||||
preTask.create_time = DateTime.Now;
|
||||
return preTask;
|
||||
}).ToList();
|
||||
//更新页面
|
||||
if (loc.is_sign == 0)
|
||||
{
|
||||
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
||||
}
|
||||
isOk = await _wareHouseService.GenPreTask(preTasks, null!, _db);
|
||||
|
||||
}
|
||||
if (isOk)
|
||||
{
|
||||
//生成预任务上传输入
|
||||
GenPreTaskUpInput preTaskUpInput = new()
|
||||
{
|
||||
RquireId = input.data["ReturnIdentity"].ToString()!,
|
||||
CarryId = carrys![i].id,
|
||||
CarryStartLocationId = points.FirstOrDefault()!.location_id!,
|
||||
CarryStartLocationCode = points.FirstOrDefault()!.location_code!,
|
||||
LocationIds = points.Select(x => x.location_id).ToList()!
|
||||
};
|
||||
|
||||
//更新明细表
|
||||
WmsEmptyOutstockD wmsEmptyOutstockD = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = preTaskUpInput.RquireId,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
|
||||
location_id = ePoint!.location_id!,
|
||||
status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID,
|
||||
carry_id = carrys[i].id,
|
||||
carry_code = carrys[i].carry_code,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
_ = await _db.Insertable(wmsEmptyOutstockD)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
//生成操作记录表
|
||||
//WmsHandleH handleH = new()
|
||||
//{
|
||||
// org_id = _userManager.User.OrganizeId,
|
||||
// startlocation_id = carrys?[i].location_id!,
|
||||
// endlocation_id = ePoint!.location_id!,
|
||||
// bill_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||
// biz_type = input.data[nameof(WmsHandleH.biz_type)]?.ToString()!,
|
||||
// carry_id = input.data[nameof(WmsHandleH.carry_id)]?.ToString()!,
|
||||
// carry_code = input.data[nameof(WmsHandleH.carry_code)]?.ToString()!,
|
||||
// require_id = input.data["ReturnIdentity"].ToString(),
|
||||
// require_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||
// create_id = _userManager.UserId,
|
||||
// create_time = DateTime.Now
|
||||
//};
|
||||
//preTaskUpInput.PreTaskRecord = handleH;
|
||||
//根据空载具出库Id,回更单据状态
|
||||
_ = await _db.Updateable<WmsEmptyOutstockH>().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
|
||||
|
||||
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
|
||||
it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
|
||||
it => new BasLocation { is_lock = 1 }, _db);
|
||||
}
|
||||
}
|
||||
|
||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carrys[i].location_id);
|
||||
}
|
||||
|
||||
if (sPoint != null && ePoint != null)
|
||||
{
|
||||
List<WmsPointH> points = new List<WmsPointH>();
|
||||
if (sPoint.area_code != ePoint.area_code)
|
||||
{
|
||||
points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
if (points.Count <= 2)
|
||||
{
|
||||
throw new AppFriendlyException($"sPoint {sPoint.point_code} ePoint{ePoint.point_code}该路径不存在", 500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points.Add(sPoint);
|
||||
points.Add(ePoint);
|
||||
}
|
||||
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTKPDA_ID, true);
|
||||
await _runService.Create(templateEntity, input);
|
||||
|
||||
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();
|
||||
//生成预任务
|
||||
WmsPretaskH preTask = new()
|
||||
{
|
||||
org_id = _userManager.User.OrganizeId,
|
||||
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 = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
|
||||
status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
|
||||
task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID,
|
||||
carry_id = carrys![i].id,
|
||||
carry_code = carrys![i].carry_code,
|
||||
area_id = sPoint?.area_id!,
|
||||
area_code = it.Key,
|
||||
require_id = input.data["ReturnIdentity"].ToString()
|
||||
};
|
||||
preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!;
|
||||
preTask.create_id = _userManager.UserId;
|
||||
preTask.create_time = DateTime.Now;
|
||||
return preTask;
|
||||
}).ToList();
|
||||
//更新页面
|
||||
if (loc.is_sign == 0)
|
||||
{
|
||||
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
|
||||
}
|
||||
isOk = await _wareHouseService.GenPreTask(preTasks, null!, _db);
|
||||
|
||||
}
|
||||
if (isOk)
|
||||
{
|
||||
//生成预任务上传输入
|
||||
GenPreTaskUpInput preTaskUpInput = new()
|
||||
{
|
||||
RquireId = input.data["ReturnIdentity"].ToString()!,
|
||||
CarryId = carrys![i].id,
|
||||
CarryStartLocationId = points.FirstOrDefault()!.location_id!,
|
||||
CarryStartLocationCode = points.FirstOrDefault()!.location_code!,
|
||||
LocationIds = points.Select(x => x.location_id).ToList()!
|
||||
};
|
||||
|
||||
//更新明细表
|
||||
WmsEmptyOutstockD wmsEmptyOutstockD = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = preTaskUpInput.RquireId,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
|
||||
location_id = ePoint!.location_id!,
|
||||
status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID,
|
||||
carry_id = carrys[i].id,
|
||||
carry_code = carrys[i].carry_code,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
_ = await _db.Insertable(wmsEmptyOutstockD)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
//生成操作记录表
|
||||
//WmsHandleH handleH = new()
|
||||
//{
|
||||
// org_id = _userManager.User.OrganizeId,
|
||||
// startlocation_id = carrys?[i].location_id!,
|
||||
// endlocation_id = ePoint!.location_id!,
|
||||
// bill_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||
// biz_type = input.data[nameof(WmsHandleH.biz_type)]?.ToString()!,
|
||||
// carry_id = input.data[nameof(WmsHandleH.carry_id)]?.ToString()!,
|
||||
// carry_code = input.data[nameof(WmsHandleH.carry_code)]?.ToString()!,
|
||||
// require_id = input.data["ReturnIdentity"].ToString(),
|
||||
// require_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||
// create_id = _userManager.UserId,
|
||||
// create_time = DateTime.Now
|
||||
//};
|
||||
//preTaskUpInput.PreTaskRecord = handleH;
|
||||
//根据空载具出库Id,回更单据状态
|
||||
_ = await _db.Updateable<WmsEmptyOutstockH>().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
|
||||
|
||||
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
|
||||
it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
|
||||
it => new BasLocation { is_lock = 1 }, _db);
|
||||
}
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
@@ -235,11 +233,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_ZC_ID)
|
||||
_s_taskExecuteSemaphore_F1ZCCOutstock.Release();
|
||||
else if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_HCC_ID)
|
||||
_s_taskExecuteSemaphore_F2HCCOutstock.Release();
|
||||
|
||||
semaphoreSlim.Release();
|
||||
await InvokeGenPretaskExcute();
|
||||
}
|
||||
return Task.FromResult(true);
|
||||
|
||||
Reference in New Issue
Block a user