执行代码清理,修复warning
This commit is contained in:
@@ -57,15 +57,30 @@ namespace Tnb.WarehouseMgr
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
var item = input.data.Adapt<WmsInstockCode>();
|
||||
if (item.codeqty == 0) throw new AppFriendlyException("请输入入库数量", 500);
|
||||
var carryCode = item.barcode;
|
||||
var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.carry_code == carryCode);
|
||||
if (carry == null) throw new AppFriendlyException("载具有误", 500);
|
||||
var mat = await _db.Queryable<BasMaterial>().FirstAsync(it => it.code == item.material_code);
|
||||
if (mat == null) throw new AppFriendlyException("物料有误", 500);
|
||||
var loc = await _db.Queryable<BasLocation>().FirstAsync(it => it.location_code == item.extras);
|
||||
if (loc == null) throw new AppFriendlyException("库位有误", 500);
|
||||
WmsInstockCode item = input.data.Adapt<WmsInstockCode>();
|
||||
if (item.codeqty == 0)
|
||||
{
|
||||
throw new AppFriendlyException("请输入入库数量", 500);
|
||||
}
|
||||
|
||||
string carryCode = item.barcode;
|
||||
WmsCarryH carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.carry_code == carryCode);
|
||||
if (carry == null)
|
||||
{
|
||||
throw new AppFriendlyException("载具有误", 500);
|
||||
}
|
||||
|
||||
BasMaterial mat = await _db.Queryable<BasMaterial>().FirstAsync(it => it.code == item.material_code);
|
||||
if (mat == null)
|
||||
{
|
||||
throw new AppFriendlyException("物料有误", 500);
|
||||
}
|
||||
|
||||
BasLocation loc = await _db.Queryable<BasLocation>().FirstAsync(it => it.location_code == item.extras);
|
||||
if (loc == null)
|
||||
{
|
||||
throw new AppFriendlyException("库位有误", 500);
|
||||
}
|
||||
|
||||
WmsInstockH instock = new()
|
||||
{
|
||||
@@ -123,65 +138,74 @@ namespace Tnb.WarehouseMgr
|
||||
create_time = DateTime.Now,
|
||||
};
|
||||
|
||||
await _db.Insertable(instock).ExecuteCommandAsync();
|
||||
await _db.Insertable(instockD).ExecuteCommandAsync();
|
||||
await _db.Insertable(instockCode).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable(instock).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable(instockD).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable(instockCode).ExecuteCommandAsync();
|
||||
|
||||
|
||||
var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = "26103372441637", Size = 1 };
|
||||
var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = "26103372441637", Size = 1 };
|
||||
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
WmsPointH sPoint = new();
|
||||
WmsPointH ePoint = new();
|
||||
|
||||
if (endLocations?.Count > 0)
|
||||
{
|
||||
var eloc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||
var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, eloc);
|
||||
if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||
BasLocation eloc = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == endLocations[0].id);
|
||||
bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, eloc);
|
||||
if (!isMatch)
|
||||
{
|
||||
throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||
}
|
||||
|
||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocations[0].id);
|
||||
}
|
||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == loc.id);
|
||||
|
||||
if (sPoint != null && ePoint != null)
|
||||
{
|
||||
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500);
|
||||
List<WmsPointH> points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
if (points.Count <= 2)
|
||||
{
|
||||
throw new AppFriendlyException("该路径不存在", 500);
|
||||
}
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||
{
|
||||
var sPoint = it.FirstOrDefault();
|
||||
var ePoint = it.LastOrDefault();
|
||||
WmsPointH? sPoint = it.FirstOrDefault();
|
||||
WmsPointH? 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.startpoint_id = sPoint?.id!;
|
||||
preTask.startpoint_code = sPoint?.point_code!;
|
||||
preTask.endpoint_id = ePoint?.id!;
|
||||
preTask.endpoint_code = ePoint?.point_code!;
|
||||
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_WMSINSTOCK_ID;
|
||||
preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
|
||||
preTask.carry_id = carry.id;
|
||||
preTask.carry_code = carry.carry_code;
|
||||
preTask.area_id = sPoint?.area_id!;
|
||||
preTask.area_code = it.Key;
|
||||
preTask.require_id = instock.id;
|
||||
preTask.require_code = instock.bill_code;
|
||||
preTask.create_id = _userManager.UserId;
|
||||
preTask.create_time = DateTime.Now;
|
||||
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_WMSINSTOCK_ID,
|
||||
task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID,
|
||||
carry_id = carry.id,
|
||||
carry_code = carry.carry_code,
|
||||
area_id = sPoint?.area_id!,
|
||||
area_code = it.Key,
|
||||
require_id = instock.id,
|
||||
require_code = instock.bill_code,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
return preTask;
|
||||
}).ToList();
|
||||
List<WmsPretaskCode> pretaskCodes = new();
|
||||
foreach (var pt in preTasks)
|
||||
foreach (WmsPretaskH? pt in preTasks)
|
||||
{
|
||||
WmsPretaskCode ptc = pt.Adapt<WmsPretaskCode>();
|
||||
ptc.id = SnowflakeIdHelper.NextId();
|
||||
@@ -194,30 +218,34 @@ namespace Tnb.WarehouseMgr
|
||||
ptc.code_batch = instockCode.code_batch;
|
||||
pretaskCodes.Add(ptc);
|
||||
}
|
||||
var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
|
||||
bool isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
|
||||
if (isOk)
|
||||
{
|
||||
|
||||
var preTaskUpInput = new GenPreTaskUpInput();
|
||||
preTaskUpInput.RquireId = instock.id;
|
||||
preTaskUpInput.CarryId = carry.id;
|
||||
preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()!.location_id!;
|
||||
preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()!.location_code!;
|
||||
preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList()!;
|
||||
GenPreTaskUpInput preTaskUpInput = new()
|
||||
{
|
||||
RquireId = instock.id,
|
||||
CarryId = carry.id,
|
||||
CarryStartLocationId = points.FirstOrDefault()!.location_id!,
|
||||
CarryStartLocationCode = points.FirstOrDefault()!.location_code!,
|
||||
LocationIds = points.Select(x => x.location_id).ToList()!
|
||||
};
|
||||
|
||||
//生成操作记录
|
||||
WmsHandleH handleH = new();
|
||||
handleH.org_id = _userManager.User.OrganizeId;
|
||||
handleH.startlocation_id = loc.id;
|
||||
handleH.endlocation_id = endLocations![0].id;
|
||||
handleH.bill_code = instock.bill_code;
|
||||
handleH.biz_type = instock.biz_type;
|
||||
handleH.carry_id = carry.id;
|
||||
handleH.carry_code = carry.carry_code;
|
||||
handleH.require_id = instock.id;
|
||||
handleH.require_code = instock.bill_code;
|
||||
handleH.create_id = _userManager.UserId;
|
||||
handleH.create_time = DateTime.Now;
|
||||
WmsHandleH handleH = new()
|
||||
{
|
||||
org_id = _userManager.User.OrganizeId,
|
||||
startlocation_id = loc.id,
|
||||
endlocation_id = endLocations![0].id,
|
||||
bill_code = instock.bill_code,
|
||||
biz_type = instock.biz_type,
|
||||
carry_id = carry.id,
|
||||
carry_code = carry.carry_code,
|
||||
require_id = instock.id,
|
||||
require_code = instock.bill_code,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
preTaskUpInput.PreTaskRecord = handleH;
|
||||
|
||||
//生成操作记录条码表
|
||||
@@ -239,14 +267,14 @@ namespace Tnb.WarehouseMgr
|
||||
wmsCarryCode.location_code = loc.location_code;
|
||||
wmsCarryCode.warehouse_id = instock.warehouse_id;
|
||||
}
|
||||
await _db.Insertable(wmsCarryCode).ExecuteCommandAsync();
|
||||
_ = await _db.Insertable(wmsCarryCode).ExecuteCommandAsync();
|
||||
|
||||
//回更状态
|
||||
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput,
|
||||
it => new WmsCarryH { carry_code = instock!.carry_code!, is_lock = 1, carry_status = ((int)EnumCarryStatus.占用).ToString(), location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
|
||||
it => new BasLocation { is_lock = 1, is_use = ((int)EnumCarryStatus.占用).ToString() });
|
||||
await _db.Updateable<WmsInstockD>().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCode.bill_d_id == it.id).ExecuteCommandAsync();
|
||||
await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == instock!.id).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<WmsInstockD>().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCode.bill_d_id == it.id).ExecuteCommandAsync();
|
||||
_ = await _db.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == instock!.id).ExecuteCommandAsync();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user