现场问题处理 人工入空托盘堆垛 塑车间信号点位统一整理为配置项等

This commit is contained in:
2024-10-23 15:30:15 +08:00
parent 5e5b3d4374
commit 5e675754e0
14 changed files with 442 additions and 265 deletions

View File

@@ -10,6 +10,7 @@ using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
using NPOI.SS.Formula;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
@@ -64,7 +65,6 @@ namespace Tnb.WarehouseMgr
semaphoreSlim = _wareHouseService.GetSemaphore("outstock", input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString());
await semaphoreSlim.WaitAsync();
Logger.Information("开始PDA空载具出库");
await _db.Ado.BeginTranAsync();
//判断目标库位是否自动签收
@@ -81,6 +81,11 @@ namespace Tnb.WarehouseMgr
};
List<WmsCarryH>? carrys = await _wareHouseService.OutStockStrategy(OutStockStrategyInput);
Logger.Information($"根据出库策略获取的载具数量:{carrys?.Count}");
if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_YCL_ID && carrys?.Count == 0)
{
return await KTPSupplymentEmptyOut(input, loc);
}
await _db.Ado.BeginTranAsync();
WmsPointH sPoint = null!;
WmsPointH ePoint = null!;
@@ -99,7 +104,7 @@ namespace Tnb.WarehouseMgr
}
//根据每个载具的起始库位做路径运算
if (carrys?.Count > 0)
{
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carrys[i].location_id);
@@ -243,6 +248,186 @@ namespace Tnb.WarehouseMgr
return Task.FromResult(true);
}
async Task<dynamic> KTPSupplymentEmptyOut(VisualDevModelDataCrInput input, BasLocation loc)
{
Logger.Information($"查找原材料仓空托盘堆垛");
await _db.Ado.BeginTranAsync();
var wmsLoc = _db.Queryable<BasLocation>()
.LeftJoin<WmsCarryH>((a, b) => a.id == b.location_id)
.Where((a, b) => a.is_lock == 0 && a.is_use == "1"
&& a.wh_id == WmsWareHouseConst.WAREHOUSE_YCL_ID && a.location_code.Contains("YCL-")
&& a.is_type == "0")
.OrderBy((a, b) => a.location_code) // 当前是按库位排序出库
.Select((a, b) => new
{
BasLocation = a,
WmsCarryH = b
}).ToList().GroupBy(p => p.BasLocation)
.Where(group =>
{
// 是否存在托盘
bool isExistsCarry = false;
foreach (var item in group)
{
if (!string.IsNullOrEmpty(item.WmsCarryH.carry_code))
{
isExistsCarry = true;
break;
}
}
if (isExistsCarry)
return false;
else
return true;
}).Select(r => r.Key).ToList();
WmsPointH sPoint = null!;
WmsPointH ePoint = null!;
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
{
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
}
int i = 0;
bool isOk = false;
Logger.Information($"PDA空载具出库实际可出空托盘堆垛数量:{wmsLoc.Count}");
if (wmsLoc.Count < 1)
{
throw new AppFriendlyException($"没有可以出库的空托盘堆垛", 500);
}
if (wmsLoc?.Count > 0)
{
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == wmsLoc[i].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 = "",
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 = "",
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 = "",
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);
}
}
else
{
throw new AppFriendlyException($"【PDAWmsEmptyOut】点位不存在", 500);
}
await _db.Ado.CommitTranAsync();
return Task.FromResult(true);
}
public override async Task ModifyAsync(WareHouseUpInput input)
{