增加报错代码

This commit is contained in:
FanLian
2023-07-13 10:26:10 +08:00
parent 35df665c73
commit 5aed4189a4
3 changed files with 96 additions and 77 deletions

View File

@@ -87,10 +87,10 @@ namespace Tnb.WarehouseMgr
if (sPoint != null && ePoint != null) if (sPoint != null && ePoint != null)
{ {
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) else
{ {
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();
@@ -153,6 +153,10 @@ namespace Tnb.WarehouseMgr
} }
} }
else
{
throw new AppFriendlyException("起始库位不可用或无可用的目标库位",500);
}
await _db.Ado.CommitTranAsync(); await _db.Ado.CommitTranAsync();
} }

View File

@@ -89,25 +89,23 @@ namespace Tnb.WarehouseMgr
WmsPointH? ePoint = null; WmsPointH? ePoint = null;
if (input.data.ContainsKey(nameof(WmsPointH.location_id))) 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()); ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString() && it.is_lock == 0);
} }
int i = 0;
//根据每个载具的起始库位做路径运算 //根据每个载具的起始库位做路径运算
for (i = 0; i < setQty.qty; i++) for (int i = 0; i < setQty.qty; i++)
{ {
if (carrys?.Count > 0) if (carrys?.Count > 0)
{
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carrys[i].location_id); sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carrys[i].location_id);
}
var isOk = false; var isOk = false;
if (sPoint != null && ePoint != null) if (sPoint != null && ePoint != null)
{ {
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) else
{ {
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();
@@ -142,7 +140,6 @@ namespace Tnb.WarehouseMgr
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值 preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
} }
isOk = await _wareHouseService.GenPreTask(preTasks, null!); isOk = await _wareHouseService.GenPreTask(preTasks, null!);
} }
if (isOk) if (isOk)
{ {
@@ -174,6 +171,10 @@ namespace Tnb.WarehouseMgr
it => new BasLocation { is_lock = 1 }); it => new BasLocation { is_lock = 1 });
} }
} }
else
{
throw new AppFriendlyException("无可出库的空载具或目标库位不存在或者目标库位被锁", 500);
}
} }
@@ -226,24 +227,24 @@ namespace Tnb.WarehouseMgr
if (input.IsNull()) throw new ArgumentNullException("input"); if (input.IsNull()) throw new ArgumentNullException("input");
try try
{ {
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code); var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code);
var dic = new Dictionary<string, object>(); var dic = new Dictionary<string, object>();
dic[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId(); dic[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId();
dic[nameof(WmsEmptyOutstockH.org_id)] = input.org_id; dic[nameof(WmsEmptyOutstockH.org_id)] = input.org_id;
dic[nameof(WmsEmptyOutstockH.location_id)] = location.id; dic[nameof(WmsEmptyOutstockH.location_id)] = location.id;
dic[nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id; dic[nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id;
dic[nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult(); dic[nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult();
dic[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID; dic[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID;
dic[nameof(WmsEmptyOutstockH.qty)] = input.qty; dic[nameof(WmsEmptyOutstockH.qty)] = input.qty;
dic[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; dic[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
dic[nameof(WmsEmptyOutstockH.create_id)] = input.create_id; dic[nameof(WmsEmptyOutstockH.create_id)] = input.create_id;
dic[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now; dic[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now;
VisualDevModelDataCrInput visualDevModelDataCrInput = new VisualDevModelDataCrInput VisualDevModelDataCrInput visualDevModelDataCrInput = new VisualDevModelDataCrInput
{ {
data = dic, data = dic,
}; };
await PDAWmsEmptyOut(visualDevModelDataCrInput); await PDAWmsEmptyOut(visualDevModelDataCrInput);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -132,71 +132,85 @@ namespace Tnb.WarehouseMgr
public async Task KittingOutByIsToBeShipped() public async Task KittingOutByIsToBeShipped()
{ {
var kittingOuts = await _db.Queryable<WmsKittingoutH>() try
.Where(a => a.status == WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID)
.OrderBy(a => a.seq)
.ToListAsync();
if (kittingOuts?.Count > 0)
{ {
var grpList = kittingOuts.GroupBy(g => g.location_id).ToList(); var kittingOuts = await _db.Queryable<WmsKittingoutH>()
foreach (var koGrp in grpList) .Where(a => a.status == WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID)
.OrderBy(a => a.seq)
.ToListAsync();
if (kittingOuts?.Count > 0)
{ {
var locs = await _db.Queryable<BasLocation>().Where(it => it.id == koGrp.Key && it.is_use == ((int)EnumCarryStatus.).ToString() && it.is_lock == 0).ToListAsync(); var grpList = kittingOuts.GroupBy(g => g.location_id).ToList();
if (locs?.Count > 0) foreach (var koGrp in grpList)
{ {
var locs = await _db.Queryable<BasLocation>().Where(it => it.id == koGrp.Key && it.is_use == ((int)EnumCarryStatus.).ToString() && it.is_lock == 0).ToListAsync();
var arr = koGrp.ToArray(); if (locs?.Count > 0)
var ko = arr[^arr.Length];
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == ko.carry_id);
if (carry != null)
{ {
WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id); var arr = koGrp.ToArray();
WmsPointH ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == ko.location_id); var ko = arr[^arr.Length];
if (sPoint != null && ePoint != null) var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == ko.carry_id);
if (carry != null)
{ {
var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id); WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carry.location_id);
if (points?.Count > 0) WmsPointH ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == ko.location_id);
if (sPoint != null && ePoint != null)
{ {
var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => if (points?.Count > 0)
{ {
var sPoint = it.FirstOrDefault(); var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
var ePoint = it.LastOrDefault(); {
var sPoint = it.FirstOrDefault();
var ePoint = it.LastOrDefault();
WmsPretaskH preTask = new(); WmsPretaskH preTask = new();
preTask.org_id = _userManager.User.OrganizeId; preTask.org_id = _userManager.User.OrganizeId;
preTask.startlocation_id = sPoint?.location_id!; preTask.startlocation_id = sPoint?.location_id!;
preTask.startlocation_code = sPoint?.location_code!; preTask.startlocation_code = sPoint?.location_code!;
preTask.endlocation_id = ePoint?.location_id!; preTask.endlocation_id = ePoint?.location_id!;
preTask.endlocation_code = ePoint?.location_code!; preTask.endlocation_code = ePoint?.location_code!;
preTask.start_floor = sPoint?.floor.ToString(); preTask.start_floor = sPoint?.floor.ToString();
preTask.end_floor = ePoint?.floor.ToString(); preTask.end_floor = ePoint?.floor.ToString();
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
preTask.biz_type = ko.biz_type; preTask.biz_type = ko.biz_type;
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID; preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
preTask.carry_id = ko!.carry_id!; preTask.carry_id = ko!.carry_id!;
preTask.carry_code = ko!.carry_code!; preTask.carry_code = ko!.carry_code!;
preTask.area_id = sPoint?.area_id!; preTask.area_id = sPoint?.area_id!;
preTask.area_code = it.Key; preTask.area_code = it.Key;
preTask.require_id = ko.id; preTask.require_id = ko.id;
preTask.require_code = ko.bill_code; preTask.require_code = ko.bill_code;
preTask.create_id = _userManager.UserId; preTask.create_id = _userManager.UserId;
preTask.create_time = DateTime.Now; preTask.create_time = DateTime.Now;
return preTask; return preTask;
}).ToList(); }).ToList();
await _warehouseService.GenPreTask(preTasks, null!); await _warehouseService.GenPreTask(preTasks, null!);
var subCarrys = await _db.Queryable<WmsCarryD>().Where(it => it.carry_id == ko.carry_id).ToListAsync(); var subCarrys = await _db.Queryable<WmsCarryD>().Where(it => it.carry_id == ko.carry_id).ToListAsync();
var carryIds = subCarrys.Select(x => x.carry_id).Concat(new[] { ko.carry_id }).Distinct().ToList(); var carryIds = subCarrys.Select(x => x.carry_id).Concat(new[] { ko.carry_id }).Distinct().ToList();
GenPreTaskUpInput genPreTaskInput = new() { CarryIds = carryIds!, LocationIds = new List<string> { carry.location_id!, ko.location_id! } }; GenPreTaskUpInput genPreTaskInput = new() { CarryIds = carryIds!, LocationIds = new List<string> { carry.location_id!, ko.location_id! } };
await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.).ToString() }, it => new BasLocation { is_lock = 1 }); await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.).ToString() }, it => new BasLocation { is_lock = 1 });
}
} }
} }
else
{
throw new AppFriendlyException("无可用的载具", 500);
}
}
else
{
throw new AppFriendlyException("无可用的库位", 500);
} }
} }
} }
} }
catch (Exception)
{
throw;
}
} }
public override async Task ModifyAsync(WareHouseUpInput input) public override async Task ModifyAsync(WareHouseUpInput input)