外协提升二楼入库、erp包材入库同步、erp重发调拨出库处理、电梯优化
This commit is contained in:
@@ -362,7 +362,7 @@ namespace Tnb.WarehouseMgr
|
||||
.OrderBy("is_lock, task_nums, location_code").ToList();
|
||||
}
|
||||
// 中储仓三工位
|
||||
else if (wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_ZC_ID)
|
||||
else if (wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_ZC_ID || wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_ZZXBK_ID)
|
||||
{
|
||||
// 根据三工位任务数平均分配任务 暂定
|
||||
endLocations = _db.Queryable<BasLocation>().Where(r => _wareHouseService.GetFloor1WXSGWOutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0")
|
||||
@@ -386,7 +386,7 @@ namespace Tnb.WarehouseMgr
|
||||
endLocation = await _db.Queryable<BasLocation>().Where(r => _wareHouseService.GetFloor1GLSGWOutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync();
|
||||
}
|
||||
// 中储仓三工位
|
||||
else if(wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_ZC_ID)
|
||||
else if(wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_ZC_ID || wmsMaterialTransfer.warehouse_instock == WmsWareHouseConst.WAREHOUSE_ZZXBK_ID)
|
||||
{
|
||||
// 根据三工位任务数平均分配任务 暂定
|
||||
endLocation = await _db.Queryable<BasLocation>().Where(r => _wareHouseService.GetFloor1WXSGWOutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync();
|
||||
@@ -599,7 +599,6 @@ namespace Tnb.WarehouseMgr
|
||||
throw new AppFriendlyException("批号不可为空", 500);
|
||||
}
|
||||
|
||||
|
||||
WmsMaterialTransferD wmsMaterialTransferD = await _db.Queryable<WmsMaterialTransferD>().FirstAsync(it => it.id == input.source_id);
|
||||
WmsMaterialTransfer wmsMaterialTransfer = await _db.Queryable<WmsMaterialTransfer>().FirstAsync(it => it.id == wmsMaterialTransferD.bill_id);
|
||||
|
||||
@@ -1455,6 +1454,10 @@ namespace Tnb.WarehouseMgr
|
||||
throw new AppFriendlyException($"载具{input.carry_code}当前所在库位不是三工位!", 500);
|
||||
}
|
||||
|
||||
if (input.qty + wmsMaterialTransferD.yxfqty_rk > wmsMaterialTransferD.yzqty)
|
||||
{
|
||||
throw new AppFriendlyException($"本次下发数量{input.qty}已超过可下发数量{wmsMaterialTransferD.yzqty - wmsMaterialTransferD.yxfqty_rk}", 500);
|
||||
}
|
||||
await _s_taskExecuteSemaphore_YCLInstock.WaitAsync();
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
@@ -2035,5 +2038,150 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 三存位入库到暂存仓
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Entities.Dto.Outputs.Result> DistributeSCWToZCC(MaterialTransferDistributeSCWToZCCInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.source_id))
|
||||
{
|
||||
throw new AppFriendlyException("来源单据id不可为空", 500);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(input.carry_code))
|
||||
{
|
||||
throw new AppFriendlyException("载具不可为空", 500);
|
||||
}
|
||||
|
||||
if (input.qty <= 0)
|
||||
{
|
||||
throw new AppFriendlyException("数量必须大于0", 500);
|
||||
}
|
||||
|
||||
WmsMaterialTransferD wmsMaterialTransferD = await _db.Queryable<WmsMaterialTransferD>().FirstAsync(it => it.id == input.source_id);
|
||||
if (wmsMaterialTransferD == null)
|
||||
{
|
||||
throw new AppFriendlyException($"不存在id为{input.source_id}的转库单明细!", 500);
|
||||
}
|
||||
|
||||
if (wmsMaterialTransferD.yxfqty_rk >= wmsMaterialTransferD.yzqty)
|
||||
{
|
||||
throw new AppFriendlyException("已下发数量已达到中储仓的转出数量", 500);
|
||||
}
|
||||
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.carry_code == input.carry_code);
|
||||
if (wmsCarryH == null)
|
||||
{
|
||||
throw new AppFriendlyException($"不存在编码为{input.carry_code}的载具!", 500);
|
||||
}
|
||||
if (wmsCarryH.carry_status != "0")
|
||||
{
|
||||
throw new AppFriendlyException($"载具{input.carry_code}状态为占用!", 500);
|
||||
}
|
||||
if (wmsCarryH.is_lock == 1)
|
||||
{
|
||||
throw new AppFriendlyException($"载具{input.carry_code}已锁定!", 500);
|
||||
}
|
||||
if (string.IsNullOrEmpty(wmsCarryH.location_id))
|
||||
{
|
||||
throw new AppFriendlyException($"载具{input.carry_code}的库位为空!", 500);
|
||||
}
|
||||
|
||||
if (wmsCarryH.carrystd_id != WmsWareHouseConst.CARRY_ZYXCSTD_ID && wmsCarryH.carrystd_id != WmsWareHouseConst.CARRY_ZYLJSTD_ID)
|
||||
{
|
||||
throw new AppFriendlyException($"载具{input.carry_code}的规格必须是载运小车或者载运料架!", 500);
|
||||
}
|
||||
|
||||
//if (!_wareHouseService.GetFloor1WXSGWOutstockLocation().Contains(wmsCarryH.location_id))
|
||||
//{
|
||||
// Logger.LogWarning($"载具{input.carry_code}当前所在库位不是三工位!");
|
||||
// throw new AppFriendlyException($"载具{input.carry_code}当前所在库位不是三工位!", 500);
|
||||
//}
|
||||
|
||||
if (input.qty + wmsMaterialTransferD.yxfqty_rk > wmsMaterialTransferD.yzqty)
|
||||
{
|
||||
throw new AppFriendlyException($"本次下发数量{input.qty}已超过可下发数量{wmsMaterialTransferD.yzqty - wmsMaterialTransferD.yxfqty_rk}", 500);
|
||||
}
|
||||
|
||||
await _s_taskExecuteSemaphore_YCLInstock.WaitAsync();
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
|
||||
InStockStrategyQuery inStockStrategyInput = new()
|
||||
{
|
||||
warehouse_id = WmsWareHouseConst.WAREHOUSE_ZCC_ID,
|
||||
Size = 1
|
||||
};
|
||||
List<BasLocation> endlocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
|
||||
if (endlocations.Count < 1)
|
||||
{
|
||||
throw new AppFriendlyException($@"没有可以入库的库位", 500);
|
||||
}
|
||||
|
||||
BasLocation startLocation = await _db.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
|
||||
|
||||
CommonCreatePretaskInput commonCreatePretaskInput = new CommonCreatePretaskInput();
|
||||
commonCreatePretaskInput.startlocation_id = startLocation.id;
|
||||
commonCreatePretaskInput.endlocation_id = endlocations[0].id;
|
||||
commonCreatePretaskInput.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID;
|
||||
commonCreatePretaskInput.biz_type = WmsWareHouseConst.BIZTYPE_WMSMATERIALTRANSFER_ID;
|
||||
// 转库单id
|
||||
commonCreatePretaskInput.source_id = input.source_id;
|
||||
commonCreatePretaskInput.carry_id = wmsCarryH.id;
|
||||
commonCreatePretaskInput.carry_code = wmsCarryH.carry_code;
|
||||
commonCreatePretaskInput.isExcuteMission = false;
|
||||
|
||||
Entities.Dto.Outputs.Result res = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput);
|
||||
|
||||
if (res.code != HttpStatusCode.OK)
|
||||
{
|
||||
throw new AppFriendlyException($@"生成预任务失败", 500);
|
||||
}
|
||||
|
||||
CarryMaterialBindInput carryMaterialBindInput = new CarryMaterialBindInput();
|
||||
carryMaterialBindInput.carrycode = wmsCarryH.carry_code;
|
||||
carryMaterialBindInput.create_id = input.create_id;
|
||||
|
||||
List<CarryMaterialDetail> carryMaterialDetails = new List<CarryMaterialDetail>();
|
||||
CarryMaterialDetail carryMaterialDetail = new CarryMaterialDetail();
|
||||
carryMaterialDetail.material_id = wmsMaterialTransferD.material_id;
|
||||
carryMaterialDetail.material_code = wmsMaterialTransferD.material_code;
|
||||
carryMaterialDetail.codeqty = input.qty;
|
||||
carryMaterialDetail.code_batch = wmsMaterialTransferD.code_batch;
|
||||
carryMaterialDetail.barcode = wmsCarryH.carry_code;
|
||||
carryMaterialDetail.unit_id = wmsMaterialTransferD.unit_id;
|
||||
carryMaterialDetails.Add(carryMaterialDetail);
|
||||
carryMaterialBindInput.details = carryMaterialDetails;
|
||||
await _wmsCarryBindService.CarryMaterialBind(carryMaterialBindInput, _db);
|
||||
await _db.Updateable<WmsCarryH>().SetColumns(r => r.carry_status == "1").Where(r => r.id == wmsCarryH.id).ExecuteCommandAsync();
|
||||
|
||||
// 更新子表已下发数量
|
||||
await _db.Updateable<WmsMaterialTransferD>().SetColumns(r => r.yxfqty_rk == r.yxfqty_rk + input.qty).Where(r => r.id == input.source_id).ExecuteCommandAsync();
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
Logger.LogWarning("【DistributeSCWToYCL】" + ex.Message);
|
||||
Logger.LogWarning("【DistributeSCWToYCL】" + ex.StackTrace);
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_ = _s_taskExecuteSemaphore_YCLInstock.Release();
|
||||
InvokeGenPretaskExcute();
|
||||
}
|
||||
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user