Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
2023-07-18 17:14:57 +08:00
8 changed files with 145 additions and 106 deletions

View File

@@ -60,17 +60,13 @@ namespace Tnb.WarehouseMgr
protected Task<bool> IsCarryAndLocationMatchByCarryStd(WmsCarryH carry, BasLocation locDest)
{
bool isMatch = false;
string errMessage = string.Empty;
if (carry == null) throw new ArgumentNullException(nameof(carry));
if (locDest == null) throw new ArgumentNullException(nameof(locDest));
if (!carry.carrystd_id.IsNullOrEmpty() && !locDest.carrystd_id.IsNullOrEmpty())
{
var jsonArr = JArray.Parse(locDest.carrystd_id);
var locCarryStdArr = jsonArr.Select(x => x.ToObject<string>()).ToArray();
if (locCarryStdArr.Contains(carry.carrystd_id))
{
isMatch = true;
}
isMatch = locCarryStdArr.Contains(carry.carrystd_id);
}
return Task.FromResult(isMatch);
}

View File

@@ -63,11 +63,17 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
//判断目标库位是否自动签收
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString());
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true);
await _runService.Create(templateEntity, input);
//入库取终点
//var OutStockStrategyInput = new OutStockStrategyQuery { carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)].ToString(), Size = 1 };
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString());
WmsPointH? sPoint = null;
WmsPointH? ePoint = null;
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
@@ -113,8 +119,6 @@ namespace Tnb.WarehouseMgr
preTask.create_time = DateTime.Now;
return preTask;
}).ToList();
//判断目标库位是否自动签收
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
if (loc.is_sign ==0 ) {
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值
}

View File

@@ -187,8 +187,6 @@ namespace Tnb.WarehouseMgr
{
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carry_code);
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code);
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
var emptyInstock = await _db.Queryable<WmsEmptyInstock>().FirstAsync(it => it.carry_code == input.carry_code && it.status == WmsWareHouseConst.BILLSTATUS_ADD_ID);
if (emptyInstock != null)
{

View File

@@ -70,8 +70,7 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTK_ID, true);
await _runService.Create(templateEntity, input);
/*//入库取终点
var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString(), Size = 1 };
@@ -85,6 +84,17 @@ namespace Tnb.WarehouseMgr
&& a.carry_status == ((int)EnumCarryStatus.).ToString() && a.is_lock == 0 && b.is_lock == 0 && b.is_type == ((int)EnumLocationType.).ToString())
.ToListAsync();
// 判断最终目标库位是否可以放置当前载具
if (carrys?.Count > 0)
{
var curCarry = carrys[^carrys.Count];
var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, loc);
if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
}
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTK_ID, true);
await _runService.Create(templateEntity, input);
WmsPointH? sPoint = null;
WmsPointH? ePoint = null;
if (input.data.ContainsKey(nameof(WmsPointH.location_id)))
@@ -92,90 +102,90 @@ namespace Tnb.WarehouseMgr
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString() && it.is_lock == 0);
}
//根据每个载具的起始库位做路径运算
for (int i = 0; i < setQty.qty; i++)
if (carrys?.Count > 0)
{
if (carrys?.Count > 0)
for (int i = 0; i < setQty.qty; i++)
{
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carrys[i].location_id);
}
var isOk = false;
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
var isOk = false;
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
else
{
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{
var sPoint = it.FirstOrDefault();
var ePoint = it.LastOrDefault();
WmsPretaskH preTask = new();
preTask.org_id = _userManager.User.OrganizeId;
preTask.startlocation_id = sPoint?.location_id!;
preTask.startlocation_code = sPoint?.location_code!;
preTask.endlocation_id = ePoint?.location_id!;
preTask.endlocation_code = ePoint?.location_code!;
preTask.start_floor = sPoint?.floor.ToString();
preTask.end_floor = ePoint?.floor.ToString();
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
preTask.carry_id = carrys![i].id;
preTask.carry_code = carrys![i].carry_code;
preTask.area_id = sPoint?.area_id!;
preTask.area_code = it.Key;
preTask.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!);
}
if (isOk)
{
var preTaskUpInput = new GenPreTaskUpInput();
preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString()!;
preTaskUpInput.CarryId = carrys![i].id;
preTaskUpInput.CarryStartLocationId = points!.FirstOrDefault()!.location_id!;
preTaskUpInput.CarryStartLocationCode = points!.FirstOrDefault()!.location_code!;
preTaskUpInput.LocationIds = points!.Select(x => x.location_id).ToList()!;
//更新明细表
WmsEmptyOutstockD wmsEmptyOutstockD = new();
wmsEmptyOutstockD.id = SnowflakeIdHelper.NextId();
wmsEmptyOutstockD.bill_id = preTaskUpInput.RquireId;
wmsEmptyOutstockD.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
wmsEmptyOutstockD.location_id = ePoint.location_id!;
wmsEmptyOutstockD.status = WmsWareHouseConst.BILLSTATUS_ON_ID;
wmsEmptyOutstockD.carry_id = carrys[i].id;
wmsEmptyOutstockD.carry_code = carrys[i].carry_code;
wmsEmptyOutstockD.create_id = _userManager.UserId;
wmsEmptyOutstockD.create_time = DateTime.Now;
await _db.Insertable(wmsEmptyOutstockD)
.ExecuteCommandAsync();
//根据空载具出库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 },
it => new BasLocation { is_lock = 1 });
}
}
else
{
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
{
var sPoint = it.FirstOrDefault();
var ePoint = it.LastOrDefault();
WmsPretaskH preTask = new();
preTask.org_id = _userManager.User.OrganizeId;
preTask.startlocation_id = sPoint?.location_id!;
preTask.startlocation_code = sPoint?.location_code!;
preTask.endlocation_id = ePoint?.location_id!;
preTask.endlocation_code = ePoint?.location_code!;
preTask.start_floor = sPoint?.floor.ToString();
preTask.end_floor = ePoint?.floor.ToString();
preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult();
preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID;
preTask.carry_id = carrys![i].id;
preTask.carry_code = carrys![i].carry_code;
preTask.area_id = sPoint?.area_id!;
preTask.area_code = it.Key;
preTask.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!);
}
if (isOk)
{
var preTaskUpInput = new GenPreTaskUpInput();
preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString()!;
preTaskUpInput.CarryId = carrys![i].id;
preTaskUpInput.CarryStartLocationId = points!.FirstOrDefault()!.location_id!;
preTaskUpInput.CarryStartLocationCode = points!.FirstOrDefault()!.location_code!;
preTaskUpInput.LocationIds = points!.Select(x => x.location_id).ToList()!;
//更新明细表
WmsEmptyOutstockD wmsEmptyOutstockD = new();
wmsEmptyOutstockD.id = SnowflakeIdHelper.NextId();
wmsEmptyOutstockD.bill_id = preTaskUpInput.RquireId;
wmsEmptyOutstockD.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID;
wmsEmptyOutstockD.location_id = ePoint.location_id!;
wmsEmptyOutstockD.status = WmsWareHouseConst.BILLSTATUS_ON_ID;
wmsEmptyOutstockD.carry_id = carrys[i].id;
wmsEmptyOutstockD.carry_code = carrys[i].carry_code;
wmsEmptyOutstockD.create_id = _userManager.UserId;
wmsEmptyOutstockD.create_time = DateTime.Now;
await _db.Insertable(wmsEmptyOutstockD)
.ExecuteCommandAsync();
//根据空载具出库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 },
it => new BasLocation { is_lock = 1 });
throw new AppFriendlyException("无可出库的空载具或目标库位不存在或者目标库位被锁", 500);
}
}
else
{
throw new AppFriendlyException("无可出库的空载具或目标库位不存在或者目标库位被锁", 500);
}
}
await _db.Ado.CommitTranAsync();
@@ -226,7 +236,7 @@ namespace Tnb.WarehouseMgr
if (input.IsNull()) throw new ArgumentNullException("input");
try
{
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code && it.is_type != EnumLocationType..ToString()) ?? throw new AppFriendlyException("无此库位或为存储库位",500);
var location = await _db.Queryable<BasLocation>().SingleAsync(it => it.location_code == input.location_code && it.is_type != EnumLocationType..ToString()) ?? throw new AppFriendlyException("无此库位或为存储库位", 500);
Dictionary<string, object> dic = new()
{
[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId(),

View File

@@ -270,10 +270,19 @@ namespace Tnb.WarehouseMgr
//入库申请条码明细表
List<WmsInstockCode> instockcodes = input.instockcodes.Adapt<List<WmsInstockCode>>();
var loc = await _db.Queryable<BasLocation>().FirstAsync(it => it.location_code == input.instock.location_code && it.is_type != EnumLocationType..ToString());
//入库取终点 //出库起点
var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = instock?.warehouse_id!, Size = 1 };
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == instock.location_id);
WmsPointH ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.instock.carry_code);
var loc = await _db.Queryable<BasLocation>().FirstAsync(it => it.id == endLocations[0].id);
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
loc = await _db.Queryable<BasLocation>().FirstAsync(it => it.location_code == input.instock.location_code && it.is_type != EnumLocationType..ToString());
//如果数据不全或有误,
if (carry.IsNull() || loc.IsNull() || instockds?.Count < 1 || instockcodes?.Count < 1)
{
@@ -329,13 +338,7 @@ namespace Tnb.WarehouseMgr
await _db.Insertable(instockCOdes).CallEntityMethod(it => it.Create(orgId)).ExecuteCommandAsync();
//生成预任务申请
//入库取终点 //出库起点
var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = instock?.warehouse_id!, Size = 1 };
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
WmsPointH sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == instock.location_id);
WmsPointH ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
if (sPoint != null && ePoint != null)
{
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);

View File

@@ -81,8 +81,8 @@ namespace Tnb.WarehouseMgr
//判断目标库位是否自动签收
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTSTOCK_ID, true);
await _runService.Create(templateEntity, input);
var carryIds = new List<string>();
@@ -178,9 +178,19 @@ namespace Tnb.WarehouseMgr
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();
}
var carrys = await _db.Queryable<WmsCarryH>().Where(it => carryIds.Contains(it.id)).ToListAsync();
if (carrys?.Count > 0)
{
var curCarry = carrys[^carrys.Count];
var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, loc);
if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTSTOCK_ID, true);
await _runService.Create(templateEntity, input);
List<WmsPretaskH> preTasks = new();
List<string> locIds = new();
foreach (var carry in carrys)
@@ -274,6 +284,9 @@ namespace Tnb.WarehouseMgr
}
await _db.Ado.CommitTranAsync();
}
catch (Exception)
@@ -333,7 +346,7 @@ namespace Tnb.WarehouseMgr
outstock.status = WmsWareHouseConst.BILLSTATUS_ADD_ID;// 新增
outstock.create_id = _userManager.UserId;
outstock.create_time = DateTime.Now;
await _db.Insertable(outstock).ExecuteCommandAsync();
//明细表
foreach (var outstockD in outstockDs!)
{
@@ -344,7 +357,7 @@ namespace Tnb.WarehouseMgr
outstock.create_time = outstock.create_time;
outstock.create_id = outstock.create_id;
}
await _db.Insertable(outstockDs).ExecuteCommandAsync();
//var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == outstock.location_id.ToString());
var carryIds = new List<string>();
//tablefield120 出库物料明细
@@ -432,6 +445,15 @@ namespace Tnb.WarehouseMgr
}
}
carryIds = allOutIds.Concat(sortingOutIds).ToList();
if(carryIds?.Count> 0)
{
var carryId = carryIds[^carryIds.Count];
var curCurry =await _db.Queryable<WmsCarryH>().SingleAsync(it=>it.id == carryId);
var isMatch = await IsCarryAndLocationMatchByCarryStd(curCurry, location);
if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
}
await _db.Insertable(outstock).ExecuteCommandAsync();
await _db.Insertable(outstockDs).ExecuteCommandAsync();
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync();
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync();

View File

@@ -63,12 +63,15 @@ namespace Tnb.WarehouseMgr
{
await _db.Ado.BeginTranAsync();
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString());
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTKPDA_ID, true);
await _runService.Create(templateEntity, input);
//出库取起点
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString());
WmsPointH? sPoint = null;
WmsPointH? ePoint = null;
WmsPointH? sPoint = null, 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());
@@ -114,7 +117,6 @@ namespace Tnb.WarehouseMgr
return preTask;
}).ToList();
//判断目标库位是否自动签收
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString());
if (loc.is_sign == 0)
{
preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值

View File

@@ -92,6 +92,10 @@ namespace Tnb.WarehouseMgr
}
if (endLocations?.Count > 0)
{
var carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString());
var loc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc);
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
}