调整wareHouseService部分代码

This commit is contained in:
alex
2023-07-14 11:07:07 +08:00
parent 1eaae0a983
commit cc6010be4e
2 changed files with 34 additions and 29 deletions

View File

@@ -251,14 +251,13 @@ namespace Tnb.WarehouseMgr
{ {
var moveNum = itGroup.First().move_num; var moveNum = itGroup.First().move_num;
var items = itGroup.Adapt<List<WmsDistaskH>>(); var items = itGroup.Adapt<List<WmsDistaskH>>();
items.ForEach(x => SnowflakeIdHelper.NextId());
items.ForEach(x => items.ForEach(x =>
{ {
x.id = SnowflakeIdHelper.NextId();
x.status = WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID; x.status = WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID;
x.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_TASK_EXECUTE_ENCODE).GetAwaiter().GetResult(); x.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_TASK_EXECUTE_ENCODE).GetAwaiter().GetResult();
}); });
var areaPreTasks = itGroup.ToList();
if (moveNum == 1) if (moveNum == 1)
{ {
items.ForEach(x => items.ForEach(x =>
@@ -269,6 +268,7 @@ namespace Tnb.WarehouseMgr
} }
else if (moveNum > 1) else if (moveNum > 1)
{ {
var areaPreTasks = itGroup.ToList();
//搬运数量==预任务数,可以生成任务执行,为任务链 //搬运数量==预任务数,可以生成任务执行,为任务链
if (moveNum == areaPreTasks.Count) if (moveNum == areaPreTasks.Count)
{ {
@@ -387,15 +387,17 @@ namespace Tnb.WarehouseMgr
await _db.Updateable<WmsDistaskH>().SetColumns(it => new WmsDistaskH { status = WmsWareHouseConst.TASK_BILL_STATUS_RUNING_ID }).Where(it => input.disTaskIds.Contains(it.id)).ExecuteCommandAsync(); await _db.Updateable<WmsDistaskH>().SetColumns(it => new WmsDistaskH { status = WmsWareHouseConst.TASK_BILL_STATUS_RUNING_ID }).Where(it => input.disTaskIds.Contains(it.id)).ExecuteCommandAsync();
//清空载具库位数据 //清空载具库位数据
var carryIds = await _db.Queryable<WmsDistaskH>().Where(it => input.disTaskIds.Contains(it.id)).Select(it => it.carry_id).ToListAsync(); var carryAndLocIds = await _db.Queryable<WmsDistaskH>().Where(it => input.disTaskIds.Contains(it.id)).Select(it => new { it.carry_id, it.startlocation_id }).ToListAsync();
if (carryIds?.Count > 0) if (carryAndLocIds?.Count > 0)
{ {
var carryIds = carryAndLocIds.Select(x => x.carry_id).ToList();
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { location_id = null, location_code = null }).Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync(); await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { location_id = null, location_code = null }).Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync();
} }
var startLocationIds = await _db.Queryable<WmsDistaskH>().Where(it => input.disTaskIds.Contains(it.id)).Select(it => it.startlocation_id).ToListAsync(); //var startLocationIds = await _db.Queryable<WmsDistaskH>().Where(it => input.disTaskIds.Contains(it.id)).Select(it => it.startlocation_id).ToListAsync();
//更新起始库位,状态改为空闲、锁定状态,未锁定 //更新起始库位,状态改为空闲、锁定状态,未锁定
if (startLocationIds?.Count > 0) if (carryAndLocIds?.Count > 0)
{ {
var startLocationIds = carryAndLocIds.Select(x => x.startlocation_id).ToList();
await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_use = ((int)EnumCarryStatus.).ToString(), is_lock = 0 }).Where(it => startLocationIds.Contains(it.id)).ExecuteCommandAsync(); await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_use = ((int)EnumCarryStatus.).ToString(), is_lock = 0 }).Where(it => startLocationIds.Contains(it.id)).ExecuteCommandAsync();
} }

View File

@@ -99,34 +99,37 @@ namespace Tnb.WarehouseMgr
{ {
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points?.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
if (points?.Count > 0) if (points?.Count > 0)
{ {
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{ {
var sPoint = it.FirstOrDefault(); var sPoint = it.FirstOrDefault();
var ePoint = it.LastOrDefault(); var ePoint = it.LastOrDefault();
WmsPretaskH preTask = new(); WmsPretaskH preTask = new()
preTask.org_id = _userManager.User.OrganizeId; {
preTask.startlocation_id = sPoint?.location_id!; org_id = _userManager.User.OrganizeId,
preTask.startlocation_code = sPoint?.location_code!; startlocation_id = sPoint?.location_id ?? "",
preTask.endlocation_id = ePoint?.location_id!; startlocation_code = sPoint?.location_code ?? "",
preTask.endlocation_code = ePoint?.location_code!; endlocation_id = ePoint?.location_id ?? "",
preTask.start_floor = sPoint?.floor.ToString(); endlocation_code = ePoint?.location_code ?? "",
preTask.end_floor = ePoint?.floor.ToString(); start_floor = sPoint?.floor.ToString(),
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); end_floor = ePoint?.floor.ToString(),
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
preTask.biz_type = input.data[nameof(WmsPretaskH.biz_type)]?.ToString()!; status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID; biz_type = input.data[nameof(WmsPretaskH.biz_type)]?.ToString() ?? "",
preTask.carry_id = input.data[nameof(preTask.carry_id)]?.ToString()!; task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID,
preTask.carry_code = input.data[nameof(preTask.carry_code)]?.ToString()!; carry_id = input.data[nameof(preTask.carry_id)]?.ToString() ?? "",
preTask.area_id = sPoint?.area_id!; carry_code = input.data[nameof(preTask.carry_code)]?.ToString() ?? "",
preTask.area_code = it.Key; area_id = sPoint?.area_id ?? "",
preTask.require_id = input.data[nameof(WmsHandleH.require_id)].ToString(); area_code = it.Key,
preTask.require_code = input.data[nameof(WmsHandleH.require_code)]?.ToString()!; require_id = input.data[nameof(WmsHandleH.require_id)].ToString(),
preTask.create_id = _userManager.UserId; require_code = input.data[nameof(WmsHandleH.require_code)]?.ToString(),
preTask.create_time = DateTime.Now; create_id = _userManager.UserId,
create_time = DateTime.Now,
};
return preTask; return preTask;
}).ToList(); }).ToList();
//生成预任务条码信息 //生成预任务条码信息
@@ -297,7 +300,7 @@ namespace Tnb.WarehouseMgr
} }
} }
await _db.Updateable(instockDetails).ExecuteCommandAsync(); await _db.Updateable(instockDetails).ExecuteCommandAsync();
var allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it=>it.bill_id ==input.requireId).ToListAsync(); var allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
if (allInstockDetails.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID)) if (allInstockDetails.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
{ {
await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();