三楼人工库逻辑等
This commit is contained in:
@@ -265,7 +265,7 @@ public partial class BasMaterial : BaseEntity<string>
|
||||
public int? deleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 箱号
|
||||
/// 箱号(弃用)
|
||||
/// </summary>
|
||||
public string container_no { get; set; }
|
||||
|
||||
@@ -275,7 +275,7 @@ public partial class BasMaterial : BaseEntity<string>
|
||||
public string? material_specification { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料型号
|
||||
/// 物料型号(箱号)
|
||||
/// </summary>
|
||||
public string? material_standard { get; set; }
|
||||
|
||||
|
||||
@@ -663,7 +663,6 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
if (_wareHouseService.s_taskExecuteSemaphore_YCLOutstock.CurrentCount == 0)
|
||||
return;
|
||||
|
||||
|
||||
var YCLInnerTransfer = await db_YCLInternalTransfer.Queryable<BasFactoryConfig>().Where(p => p.key == "YCLInnerTransfer").FirstAsync();
|
||||
// 0则不进行移转
|
||||
if (YCLInnerTransfer != null && YCLInnerTransfer.value == "0")
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
/// <summary>
|
||||
/// 成品库人工出库区
|
||||
/// </summary>
|
||||
public const string REGION_CPManualOutstock_ID = "36539312699413";
|
||||
public const string REGION_CPManualOutstock_ID = "36543552166677";
|
||||
/// <summary>
|
||||
/// 长管出库
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Tnb.WarehouseMgr.Entities.Dto
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 库房业务更新输入参数
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
/// <summary>
|
||||
/// 终点库位
|
||||
/// </summary>
|
||||
public string? endlocation_id { get; set; }
|
||||
public string? endlocation_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 载具
|
||||
|
||||
@@ -134,4 +134,8 @@ public partial class WmsRawmatTransferoutstockH : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? instockorg_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// erp_bill_code
|
||||
/// </summary>
|
||||
public string? erp_bill_code { get; set; }
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public partial class WmsTransferOrderD : BaseEntity<string>
|
||||
public string erp_wh_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// erp入库仓库编码
|
||||
/// erp入库仓库id
|
||||
/// </summary>
|
||||
public string? warehouse_instock_code { get; set; }
|
||||
}
|
||||
|
||||
@@ -118,4 +118,10 @@ public partial class WmsTransferOutstockH : BaseEntity<string>
|
||||
/// bip入库组织id
|
||||
/// </summary>
|
||||
public string? instockorg_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// erp_bill_code
|
||||
/// </summary>
|
||||
public string? erp_bill_code { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -51,6 +51,15 @@ namespace Tnb.WarehouseMgr.Interfaces
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取锁
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="warehouse_id"></param>
|
||||
/// <param name="region_id"></param>
|
||||
/// <returns></returns>
|
||||
SemaphoreSlim GetSemaphore(string type, string warehouse_id, string region_id = "");
|
||||
|
||||
/// <summary>
|
||||
/// 入库策略
|
||||
/// </summary>
|
||||
|
||||
@@ -44,25 +44,55 @@ namespace Tnb.WarehouseMgr
|
||||
[LogLevel.Error] = "ERR",
|
||||
};
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
public static SemaphoreSlim s_taskExecuteSemaphore = new(1);
|
||||
public static SemaphoreSlim s_elevatorStatusSemaphore = new(1);
|
||||
|
||||
/// <summary>
|
||||
/// 原材料
|
||||
/// </summary>
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_YCLInstock = new(1);
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_YCLOutstock = new(1);
|
||||
|
||||
/// <summary>
|
||||
/// 中储仓
|
||||
/// </summary>
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F1ZCCInstock = new(1);
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F1ZCCOutstock = new(1);
|
||||
|
||||
/// <summary>
|
||||
/// 暂存仓
|
||||
/// </summary>
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F2ZCCInstock = new(1);
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F2ZCCOutstock = new(1);
|
||||
|
||||
/// <summary>
|
||||
/// 缓存仓
|
||||
/// </summary>
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F2HCCInstock = new(1);
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F2HCCOutstock = new(1);
|
||||
|
||||
/// <summary>
|
||||
/// 待灭菌仓
|
||||
/// </summary>
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F4DMJCInstock = new(1);
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F4DMJCOutstock = new(1);
|
||||
|
||||
/// <summary>
|
||||
/// 成品仓
|
||||
/// </summary>
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F3CPInstock = new(1);
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F3CPOutstock = new(1);
|
||||
/// <summary>
|
||||
/// 四楼包材库
|
||||
/// </summary>
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F4BCKInstock = new(1);
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F4BCKOutstock = new(1);
|
||||
/// <summary>
|
||||
/// 二楼包材库
|
||||
/// </summary>
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F2BCQInstock = new(1);
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_F2BCQOutstock = new(1);
|
||||
/// <summary>
|
||||
/// 出入库明细
|
||||
/// </summary>
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_AddOutinStockDetail = new(1);
|
||||
/// <summary>
|
||||
/// 编码规则
|
||||
/// </summary>
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_codeRules = new(1);
|
||||
|
||||
protected static Dictionary<string, int> _s_eleUseStatusDic;
|
||||
|
||||
@@ -432,7 +432,7 @@ namespace Tnb.WarehouseMgr
|
||||
await _db.Updateable<WmsElevatorH>().SetColumns(r => new WmsElevatorH
|
||||
{
|
||||
is_use = (int)EnumElevatorUseStatus.占用,
|
||||
use_tasks = $"','{ r.use_tasks }".Trim(',')
|
||||
use_tasks = $"','{r.use_tasks}".Trim(',')
|
||||
}).Where(r => r.elevator_id == elevator.device_id).ExecuteCommandAsync();
|
||||
s_eleUseStatusDic[elevator.device_id] = (int)EnumElevatorUseStatus.占用;
|
||||
Logger.Information($"【UnloadConfirm】 {devName}放货成功 状态变更为占用 {s_eleUseStatusDic.GetHashCode()} {s_eleUseStatusDic[elevator.device_id]}");
|
||||
@@ -521,72 +521,76 @@ namespace Tnb.WarehouseMgr
|
||||
Logger.Information($"【TaskChainCallBack】{wmsDistaskH.bill_code} 执行取消电梯任务时 任务数变更{eleRow}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Information($"【TaskChainCallBack】{wmsDistaskH.bill_code} 执行取消电梯任务时 电梯id{e.device_id}找不到对应电梯资料");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Information($"【TaskChainCallBack】{wmsDistaskH.bill_code} 判断不是在执行取消电梯任务");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (wmsDistaskH.startlocation_code.Contains("DT") || wmsDistaskH.endlocation_code.Contains("DT"))
|
||||
|
||||
|
||||
|
||||
if (wmsDistaskH.act_start_date == null)
|
||||
{
|
||||
//WmsElevatorUnlockInput wmsElevatorUnlockInput = new ();
|
||||
//wmsElevatorUnlockInput.elevator_id = wmsDistaskH.device_id;
|
||||
//await WmsElevatorUnlock(wmsElevatorUnlockInput);
|
||||
//Logger.Information($"WCS取消任务{wmsDistaskH.bill_code},自动解占用电梯{wmsDistaskH.device_id}");
|
||||
int unlockStartRow = await _db.Updateable<BasLocation>().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.startlocation_code).ExecuteCommandAsync();
|
||||
if (unlockStartRow > 0)
|
||||
Logger.Information($"成功解锁起点库位{wmsDistaskH.startlocation_code}");
|
||||
else
|
||||
Logger.Information($"未成功解锁起点库位{wmsDistaskH.startlocation_code}");
|
||||
}
|
||||
|
||||
int unlockEndRow = await _db.Updateable<BasLocation>().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.endlocation_code).ExecuteCommandAsync();
|
||||
if (unlockEndRow > 0)
|
||||
Logger.Information($"成功解锁终点库位{wmsDistaskH.endlocation_code}");
|
||||
else
|
||||
Logger.Information($"未成功解锁终点库位{wmsDistaskH.endlocation_code}");
|
||||
|
||||
#region 当前任务后续未开始的任务全取消,并解锁库位
|
||||
WmsPretaskH curWmsPretaskH = await _db.Queryable<WmsPretaskH>().Where(r => r.bill_code == wmsDistaskH.pretask_code).FirstAsync();
|
||||
List<WmsPretaskH> nextWmsPretaskHs = _db.Queryable<WmsPretaskH>().Where(r => r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID
|
||||
&& r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID && r.carry_code == wmsDistaskH.carry_code && long.Parse(r.id) > long.Parse(curWmsPretaskH.id)).ToList();
|
||||
Logger.Information($"即将取消{wmsDistaskH.bill_code}的后续预任务{nextWmsPretaskHs.Count}条");
|
||||
foreach (WmsPretaskH wmsPretaskH in nextWmsPretaskHs)
|
||||
{
|
||||
// 排除电梯任务 其他任务取消时自动解锁起点和终点库位
|
||||
|
||||
if (wmsDistaskH.act_start_date == null)
|
||||
int _row = await _db.Updateable<WmsPretaskH>().SetColumns(r => new WmsPretaskH
|
||||
{
|
||||
int unlockStartRow = await _db.Updateable<BasLocation>().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.startlocation_code).ExecuteCommandAsync();
|
||||
if (unlockStartRow > 0)
|
||||
{
|
||||
Logger.Information($"成功解锁起点库位{wmsDistaskH.startlocation_code}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Information($"未成功解锁起点库位{wmsDistaskH.startlocation_code}");
|
||||
}
|
||||
}
|
||||
|
||||
int unlockEndRow = await _db.Updateable<BasLocation>().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.endlocation_code).ExecuteCommandAsync();
|
||||
if (unlockEndRow > 0)
|
||||
{
|
||||
Logger.Information($"成功解锁终点库位{wmsDistaskH.endlocation_code}");
|
||||
}
|
||||
note = "WCS上传失败(CANCELLED)信号",
|
||||
status = WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID
|
||||
}).Where(P => P.bill_code == wmsPretaskH.bill_code).ExecuteCommandAsync();
|
||||
if (_row > 0)
|
||||
Logger.Information($"成功取消后续预任务{wmsPretaskH.bill_code}");
|
||||
else
|
||||
{
|
||||
Logger.Information($"未成功解锁终点库位{wmsDistaskH.endlocation_code}");
|
||||
}
|
||||
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.carry_code == wmsDistaskH.carry_code).FirstAsync();
|
||||
wmsCarryH.is_lock = 0;
|
||||
if (wmsDistaskH.startlocation_code.Contains("BGWRKYCL0"))
|
||||
{
|
||||
wmsCarryH.location_id = WmsWareHouseConst.LOCATION_YCLBGWDRK;
|
||||
wmsCarryH.location_code = "YCLBGWDRK";
|
||||
}
|
||||
|
||||
int unlockCarryRow = await _db.Updateable(wmsCarryH).ExecuteCommandAsync();
|
||||
if (unlockCarryRow > 0)
|
||||
{
|
||||
Logger.Information($"成功解锁载具{wmsDistaskH.carry_code}");
|
||||
}
|
||||
Logger.Information($"未成功取消后续预任务{wmsPretaskH.bill_code}");
|
||||
int _unlockStartRow = await _db.Updateable<BasLocation>().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsPretaskH.startlocation_code).ExecuteCommandAsync();
|
||||
if (_unlockStartRow > 0)
|
||||
Logger.Information($"成功解锁起点库位{wmsPretaskH.startlocation_code}");
|
||||
else
|
||||
{
|
||||
Logger.Information($"未成功解锁载具{wmsDistaskH.carry_code}");
|
||||
}
|
||||
|
||||
Logger.Information($"未成功解锁起点库位{wmsPretaskH.startlocation_code}");
|
||||
int _unlockEndRow = await _db.Updateable<BasLocation>().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsPretaskH.endlocation_code).ExecuteCommandAsync();
|
||||
if (_unlockEndRow > 0)
|
||||
Logger.Information($"成功解锁终点库位{wmsPretaskH.endlocation_code}");
|
||||
else
|
||||
Logger.Information($"未成功解锁终点库位{wmsPretaskH.endlocation_code}");
|
||||
}
|
||||
#endregion
|
||||
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.carry_code == wmsDistaskH.carry_code).FirstAsync();
|
||||
wmsCarryH.is_lock = 0;
|
||||
if (wmsDistaskH.startlocation_code.Contains("BGWRKYCL0"))
|
||||
{
|
||||
wmsCarryH.location_id = WmsWareHouseConst.LOCATION_YCLBGWDRK;
|
||||
wmsCarryH.location_code = "YCLBGWDRK";
|
||||
}
|
||||
|
||||
int unlockCarryRow = await _db.Updateable(wmsCarryH).ExecuteCommandAsync();
|
||||
if (unlockCarryRow > 0)
|
||||
Logger.Information($"成功解锁载具{wmsDistaskH.carry_code}");
|
||||
else
|
||||
Logger.Information($"未成功解锁载具{wmsDistaskH.carry_code}");
|
||||
|
||||
}
|
||||
|
||||
// 任务链取消
|
||||
await _db.Updateable<WmsPretaskH>().SetColumns(r => new WmsPretaskH
|
||||
{
|
||||
note = "WCS上传取消(CANCELLED)信号",
|
||||
@@ -607,7 +611,7 @@ namespace Tnb.WarehouseMgr
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case "SUCCEED": break;
|
||||
@@ -645,70 +649,74 @@ namespace Tnb.WarehouseMgr
|
||||
Logger.Information($"【TaskChainCallBack】{wmsDistaskH.bill_code} 执行取消电梯任务时 任务数变更{eleRow}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Information($"【TaskChainCallBack】{wmsDistaskH.bill_code} 执行电梯任务时 电梯id{e.device_id}找不到对应电梯资料");
|
||||
}
|
||||
Logger.Information($"【TaskChainCallBack】{wmsDistaskH.bill_code} 执行取消电梯任务时 电梯id{e.device_id}找不到对应电梯资料");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Information($"【TaskChainCallBack】{wmsDistaskH.bill_code} 判断不是在执行电梯任务");
|
||||
|
||||
|
||||
|
||||
if (wmsDistaskH.act_start_date == null)
|
||||
{
|
||||
int unlockStartRow = await _db.Updateable<BasLocation>().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.startlocation_code).ExecuteCommandAsync();
|
||||
if (unlockStartRow > 0)
|
||||
Logger.Information($"成功解锁起点库位{wmsDistaskH.startlocation_code}");
|
||||
else
|
||||
Logger.Information($"未成功解锁起点库位{wmsDistaskH.startlocation_code}");
|
||||
}
|
||||
|
||||
if (wmsDistaskH.startlocation_code.Contains("DT") || wmsDistaskH.endlocation_code.Contains("DT"))
|
||||
{
|
||||
//WmsElevatorUnlockInput wmsElevatorUnlockInput = new ();
|
||||
//wmsElevatorUnlockInput.elevator_id = wmsDistaskH.device_id;
|
||||
//await WmsElevatorUnlock(wmsElevatorUnlockInput);
|
||||
//Logger.Information($"WCS取消任务{wmsDistaskH.bill_code},自动解占用电梯{wmsDistaskH.device_id}");
|
||||
}
|
||||
int unlockEndRow = await _db.Updateable<BasLocation>().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.endlocation_code).ExecuteCommandAsync();
|
||||
if (unlockEndRow > 0)
|
||||
Logger.Information($"成功解锁终点库位{wmsDistaskH.endlocation_code}");
|
||||
else
|
||||
Logger.Information($"未成功解锁终点库位{wmsDistaskH.endlocation_code}");
|
||||
|
||||
#region 当前任务后续未开始的任务全取消,并解锁库位
|
||||
WmsPretaskH curWmsPretaskH = await _db.Queryable<WmsPretaskH>().Where(r => r.bill_code == wmsDistaskH.pretask_code).FirstAsync();
|
||||
List<WmsPretaskH> nextWmsPretaskHs = _db.Queryable<WmsPretaskH>().Where(r => r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID
|
||||
&& r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID && r.carry_code == wmsDistaskH.carry_code && long.Parse(r.id) > long.Parse(curWmsPretaskH.id)).ToList();
|
||||
Logger.Information($"即将取消{wmsDistaskH.bill_code}的后续预任务{nextWmsPretaskHs.Count}条");
|
||||
foreach (WmsPretaskH wmsPretaskH in nextWmsPretaskHs)
|
||||
{
|
||||
// 排除电梯任务 其他任务取消时自动解锁起点和终点库位
|
||||
|
||||
if (wmsDistaskH.act_start_date == null)
|
||||
int _row = await _db.Updateable<WmsPretaskH>().SetColumns(r => new WmsPretaskH
|
||||
{
|
||||
int unlockStartRow = await _db.Updateable<BasLocation>().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.startlocation_code).ExecuteCommandAsync();
|
||||
if (unlockStartRow > 0)
|
||||
{
|
||||
Logger.Information($"成功解锁起点库位{wmsDistaskH.startlocation_code}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Information($"未成功解锁起点库位{wmsDistaskH.startlocation_code}");
|
||||
}
|
||||
}
|
||||
|
||||
int unlockEndRow = await _db.Updateable<BasLocation>().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.endlocation_code).ExecuteCommandAsync();
|
||||
if (unlockEndRow > 0)
|
||||
{
|
||||
Logger.Information($"成功解锁终点库位{wmsDistaskH.endlocation_code}");
|
||||
}
|
||||
note = "WCS上传失败(FAILURE)信号",
|
||||
status = WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID
|
||||
}).Where(P => P.bill_code == wmsPretaskH.bill_code).ExecuteCommandAsync();
|
||||
if (_row > 0)
|
||||
Logger.Information($"成功取消后续预任务{wmsPretaskH.bill_code}");
|
||||
else
|
||||
{
|
||||
Logger.Information($"未成功解锁终点库位{wmsDistaskH.endlocation_code}");
|
||||
}
|
||||
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.carry_code == wmsDistaskH.carry_code).FirstAsync();
|
||||
wmsCarryH.is_lock = 0;
|
||||
if (wmsDistaskH.startlocation_code.Contains("BGWRKYCL0"))
|
||||
{
|
||||
wmsCarryH.location_id = WmsWareHouseConst.LOCATION_YCLBGWDRK;
|
||||
wmsCarryH.location_code = "YCLBGWDRK";
|
||||
}
|
||||
|
||||
int unlockCarryRow = await _db.Updateable(wmsCarryH).ExecuteCommandAsync();
|
||||
if (unlockCarryRow > 0)
|
||||
{
|
||||
Logger.Information($"成功解锁载具{wmsDistaskH.carry_code}");
|
||||
}
|
||||
Logger.Information($"未成功取消后续预任务{wmsPretaskH.bill_code}");
|
||||
int _unlockStartRow = await _db.Updateable<BasLocation>().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsPretaskH.startlocation_code).ExecuteCommandAsync();
|
||||
if (_unlockStartRow > 0)
|
||||
Logger.Information($"成功解锁起点库位{wmsPretaskH.startlocation_code}");
|
||||
else
|
||||
{
|
||||
Logger.Information($"未成功解锁载具{wmsDistaskH.carry_code}");
|
||||
}
|
||||
Logger.Information($"未成功解锁起点库位{wmsPretaskH.startlocation_code}");
|
||||
int _unlockEndRow = await _db.Updateable<BasLocation>().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsPretaskH.endlocation_code).ExecuteCommandAsync();
|
||||
if (_unlockEndRow > 0)
|
||||
Logger.Information($"成功解锁终点库位{wmsPretaskH.endlocation_code}");
|
||||
else
|
||||
Logger.Information($"未成功解锁终点库位{wmsPretaskH.endlocation_code}");
|
||||
}
|
||||
#endregion
|
||||
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.carry_code == wmsDistaskH.carry_code).FirstAsync();
|
||||
wmsCarryH.is_lock = 0;
|
||||
if (wmsDistaskH.startlocation_code.Contains("BGWRKYCL0"))
|
||||
{
|
||||
wmsCarryH.location_id = WmsWareHouseConst.LOCATION_YCLBGWDRK;
|
||||
wmsCarryH.location_code = "YCLBGWDRK";
|
||||
}
|
||||
|
||||
int unlockCarryRow = await _db.Updateable(wmsCarryH).ExecuteCommandAsync();
|
||||
if (unlockCarryRow > 0)
|
||||
Logger.Information($"成功解锁载具{wmsDistaskH.carry_code}");
|
||||
else
|
||||
Logger.Information($"未成功解锁载具{wmsDistaskH.carry_code}");
|
||||
}
|
||||
|
||||
|
||||
// 任务链取消
|
||||
await _db.Updateable<WmsPretaskH>().SetColumns(r => new WmsPretaskH
|
||||
{
|
||||
note = "WCS上传失败(FAILURE)信号",
|
||||
@@ -729,7 +737,7 @@ namespace Tnb.WarehouseMgr
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case "FINISHED":
|
||||
@@ -771,6 +779,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 任务状态上报
|
||||
/// </summary>
|
||||
@@ -781,7 +790,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
var disTask = await _db.Queryable<WmsDistaskH>().FirstAsync(it => it.bill_code == input.taskCode);
|
||||
|
||||
|
||||
|
||||
Logger.Information($"【TaskCallback】 【接收】{input.taskCode} WCS信号 任务状态上报->接收参数:{JsonConvert.SerializeObject(input)}");
|
||||
try
|
||||
{
|
||||
|
||||
@@ -688,8 +688,8 @@ namespace Tnb.WarehouseMgr
|
||||
WmsErpWarehouserelaH wmsErpWarehouserelaHin = await db.Queryable<WmsErpWarehouserelaH>().Where(r => r.erp_warehousecode == input.warehouse_instock).FirstAsync();
|
||||
if (wmsErpWarehouserelaHin == null)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【TransferOrder】不存在erp仓库类型{input.warehouse_outstock}对应wms系统的映射关系!");
|
||||
throw new AppFriendlyException($@"不存在erp仓库类型{input.warehouse_outstock}对应wms系统的映射关系!", 500);
|
||||
_LoggerErp2Mes.LogWarning($@"【TransferOrder】不存在erp仓库类型{input.warehouse_instock}对应wms系统的映射关系!");
|
||||
throw new AppFriendlyException($@"不存在erp仓库类型{input.warehouse_instock}对应wms系统的映射关系!", 500);
|
||||
}
|
||||
|
||||
string warehouse_outstock_code = wmsErpWarehouserelaHout.wms_warehousecode;
|
||||
@@ -840,7 +840,8 @@ namespace Tnb.WarehouseMgr
|
||||
wmsMaterialTransferD.material_specification = material.material_specification;
|
||||
}
|
||||
|
||||
var erpExtendField = await db.Queryable<ErpExtendField>().InnerJoin<DictionaryDataEntity>((a, b) => a.table_id == b.Id).Where((a, b) => b.EnCode == detail.unit_code).Select((a, b) => b).FirstAsync();
|
||||
|
||||
var erpExtendField = await db.Queryable<ErpExtendField>().InnerJoin<DictionaryDataEntity>((a, b) => a.table_id == b.Id).Where((a, b) => a.cunitid == detail.unit_code).Select((a, b) => b).FirstAsync();
|
||||
if (erpExtendField != null)
|
||||
{
|
||||
wmsMaterialTransferD.unit_id = erpExtendField.Id;
|
||||
@@ -895,7 +896,7 @@ namespace Tnb.WarehouseMgr
|
||||
wmsPrdReturnD.material_name = material.name;
|
||||
}
|
||||
|
||||
var erpExtendField = await db.Queryable<ErpExtendField>().InnerJoin<DictionaryDataEntity>((a, b) => a.table_id == b.Id).Where((a, b) => b.EnCode == detail.unit_code).Select((a, b) => b).FirstAsync();
|
||||
var erpExtendField = await db.Queryable<ErpExtendField>().InnerJoin<DictionaryDataEntity>((a, b) => a.table_id == b.Id).Where((a, b) => a.cunitid == detail.unit_code).Select((a, b) => b).FirstAsync();
|
||||
if (erpExtendField != null)
|
||||
{
|
||||
wmsPrdReturnD.unit_id = erpExtendField.Id;
|
||||
@@ -1511,12 +1512,12 @@ namespace Tnb.WarehouseMgr
|
||||
b.whcode
|
||||
})
|
||||
.ToDictionaryAsync(k => k.erp_warehousecode, v => v.id);
|
||||
foreach (var key in dic_WmsErpWarehouseidrelaH.Keys)
|
||||
foreach (var detail in input.details)
|
||||
{
|
||||
if (dic_WmsErpWarehouseidrelaH[key] == null)
|
||||
if (!dic_WmsErpWarehouseidrelaH.ContainsKey(detail.warehouse_outstock))
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($"【TransferOrder】无法查询到出库仓库{key}的档案记录!");
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, $"无法查询到出库仓库{key}的档案记录!");
|
||||
_LoggerErp2Mes.LogWarning($"【TransferOrder】无法查询到出库仓库{detail.warehouse_outstock}的档案记录!");
|
||||
throw new AppFriendlyException($"无法查询到出库仓库{detail.warehouse_outstock}的档案记录!", 500);
|
||||
}
|
||||
}
|
||||
Dictionary<string, object> dic_WmsErpWarehousecoderelaH = await db.Queryable<WmsErpWarehouserelaH>()
|
||||
@@ -1599,6 +1600,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
WmsRawmatTransferoutstockH wmsRawmatTransferoutstockH = new WmsRawmatTransferoutstockH();
|
||||
string code = await _billRuleService.GetBillNumber("RawmatTransferoutstock");
|
||||
wmsRawmatTransferoutstockH.erp_bill_code = input.transfer_order;
|
||||
wmsRawmatTransferoutstockH.bill_code = code;
|
||||
wmsRawmatTransferoutstockH.create_id = WmsWareHouseConst.ErpUserId;
|
||||
wmsRawmatTransferoutstockH.create_time = DateTime.Now;
|
||||
@@ -1677,6 +1679,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
WmsTransferOutstockH wmsTransferOutstockH = new WmsTransferOutstockH();
|
||||
string code = await _billRuleService.GetBillNumber("WmsTransferOutstock");
|
||||
wmsTransferOutstockH.erp_bill_code = input.transfer_order;
|
||||
wmsTransferOutstockH.bill_code = code;
|
||||
wmsTransferOutstockH.create_id = WmsWareHouseConst.ErpUserId;
|
||||
wmsTransferOutstockH.create_time = DateTime.Now;
|
||||
|
||||
@@ -2337,7 +2337,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"通知WCS电梯{devName}下行接口调用成功");
|
||||
Logger.Information($"通知WCS电梯{devName}下行接口调用成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3100,21 +3100,42 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
WmsElevatorH wmsElevatorH = await _db.Queryable<WmsElevatorH>().Where(it => it.elevator_group == "2" && it.enabled == 1).OrderBy(r => r.task_nums).FirstAsync();
|
||||
string elevatorSno = wmsElevatorH.elevator_code.Replace("Elevator", "");
|
||||
|
||||
List<BasLocation> locations = await _db.Queryable<BasLocation>()
|
||||
.InnerJoin<WmsPointH>((a, b) => a.id == b.location_id)
|
||||
.InnerJoin<WmsPointD>((a, b, c) => b.id == c.point_id)
|
||||
.InnerJoin<WmsPointH>((a, b, c, d) => d.id == c.endpoint_id)
|
||||
.Where((a, b, c, d) => a.wh_id == WmsWareHouseConst.WAREHOUSE_CP_ID && a.region_id == WmsWareHouseConst.REGION_CPOutstockCache_ID && d.point_code == $"DT-3-{elevatorSno}")
|
||||
.Where((a, b, c, d) => a.wh_id == WmsWareHouseConst.WAREHOUSE_CP_ID
|
||||
&& a.is_lock == 0 && a.is_use == "0"
|
||||
&& a.region_id == WmsWareHouseConst.REGION_CPOutstockCache_ID && d.point_code == $"DT-3-{elevatorSno}")
|
||||
.Select((a, b, c, d) => new BasLocation
|
||||
{
|
||||
location_code = a.location_code,
|
||||
extras = d.point_code
|
||||
}).OrderBy("a.is_lock, a.is_use, a.location_code, d.point_code").ToListAsync();
|
||||
}).OrderBy("a.location_code, d.point_code").ToListAsync();
|
||||
// 如果没有空闲库位 再找一下另一个电梯的缓存区有没有空闲库位
|
||||
if (locations.Count == 0)
|
||||
{
|
||||
elevatorSno = elevatorSno == "3" ? "4" : "3";
|
||||
locations = await _db.Queryable<BasLocation>()
|
||||
.InnerJoin<WmsPointH>((a, b) => a.id == b.location_id)
|
||||
.InnerJoin<WmsPointD>((a, b, c) => b.id == c.point_id)
|
||||
.InnerJoin<WmsPointH>((a, b, c, d) => d.id == c.endpoint_id)
|
||||
.Where((a, b, c, d) => a.wh_id == WmsWareHouseConst.WAREHOUSE_CP_ID
|
||||
&& a.is_lock == 0 && a.is_use == "0"
|
||||
&& a.region_id == WmsWareHouseConst.REGION_CPOutstockCache_ID && d.point_code == $"DT-3-{elevatorSno}")
|
||||
.Select((a, b, c, d) => new BasLocation
|
||||
{
|
||||
location_code = a.location_code,
|
||||
extras = d.point_code
|
||||
}).OrderBy("a.location_code, d.point_code").ToListAsync();
|
||||
}
|
||||
|
||||
if (locations.Count == 0)
|
||||
{
|
||||
throw new AppFriendlyException($"三楼发货时,没有可用的暂存库位可以使用", 500);
|
||||
}
|
||||
|
||||
BasLocation cache_location = locations.First();
|
||||
// 到暂存区
|
||||
points.Add(wmsPointHs.Where(r => r.id == pStartId).First());
|
||||
@@ -4055,6 +4076,79 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
|
||||
public SemaphoreSlim GetSemaphore(string type, string warehouse_id, string region_id = "")
|
||||
{
|
||||
SemaphoreSlim result = null;
|
||||
switch (warehouse_id)
|
||||
{
|
||||
case WmsWareHouseConst.WAREHOUSE_ZC_ID:
|
||||
{
|
||||
if (type == "outstock")
|
||||
result = _s_taskExecuteSemaphore_F1ZCCOutstock;
|
||||
else if (type == "instock")
|
||||
result = _s_taskExecuteSemaphore_F1ZCCInstock;
|
||||
break;
|
||||
}
|
||||
case WmsWareHouseConst.WAREHOUSE_HCC_ID:
|
||||
{
|
||||
if (type == "outstock")
|
||||
result = _s_taskExecuteSemaphore_F2HCCOutstock;
|
||||
else if (type == "instock")
|
||||
result = _s_taskExecuteSemaphore_F2HCCInstock;
|
||||
|
||||
break;
|
||||
}
|
||||
case WmsWareHouseConst.WAREHOUSE_YCL_ID:
|
||||
{
|
||||
if (type == "outstock")
|
||||
result = _s_taskExecuteSemaphore_YCLOutstock;
|
||||
else if (type == "instock")
|
||||
result = _s_taskExecuteSemaphore_YCLInstock;
|
||||
break;
|
||||
}
|
||||
case WmsWareHouseConst.WAREHOUSE_CP_ID:
|
||||
{
|
||||
if (type == "outstock")
|
||||
result = _s_taskExecuteSemaphore_F3CPOutstock;
|
||||
else if (type == "instock")
|
||||
result = _s_taskExecuteSemaphore_F3CPInstock;
|
||||
break;
|
||||
}
|
||||
case WmsWareHouseConst.WAREHOUSE_ZCC_ID:
|
||||
{
|
||||
if (type == "outstock")
|
||||
result = _s_taskExecuteSemaphore_F2ZCCOutstock;
|
||||
else if (type == "instock")
|
||||
result = _s_taskExecuteSemaphore_F2ZCCInstock;
|
||||
break;
|
||||
}
|
||||
case WmsWareHouseConst.WAREHOUSE_DMJC_ID:
|
||||
{
|
||||
if (type == "outstock")
|
||||
result = _s_taskExecuteSemaphore_F4DMJCOutstock;
|
||||
else if (type == "instock")
|
||||
result = _s_taskExecuteSemaphore_F4DMJCInstock;
|
||||
break;
|
||||
}
|
||||
case WmsWareHouseConst.WAREHOUSE_BCK_ID:
|
||||
{
|
||||
if (type == "outstock")
|
||||
result = _s_taskExecuteSemaphore_F4BCKOutstock;
|
||||
else if (type == "instock")
|
||||
result = _s_taskExecuteSemaphore_F4BCKInstock;
|
||||
break;
|
||||
}
|
||||
case WmsWareHouseConst.WAREHOUSE_F2BCQ_ID:
|
||||
{
|
||||
if (type == "outstock")
|
||||
result = _s_taskExecuteSemaphore_F2BCQOutstock;
|
||||
else if (type == "instock")
|
||||
result = _s_taskExecuteSemaphore_F2BCQInstock;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return _s_taskExecuteSemaphore_F1ZCCOutstock;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -65,12 +65,11 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
public async Task<dynamic> WmsEmptyOut(VisualDevModelDataCrInput input)
|
||||
{
|
||||
if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_ZC_ID)
|
||||
{
|
||||
await _s_taskExecuteSemaphore_F1ZCCOutstock.WaitAsync();
|
||||
}
|
||||
SemaphoreSlim semaphoreSlim = null;
|
||||
try
|
||||
{
|
||||
semaphoreSlim = _wareHouseService.GetSemaphore("outstock", input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString());
|
||||
await semaphoreSlim.WaitAsync();
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
/*//入库取终点
|
||||
@@ -260,10 +259,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_ZC_ID)
|
||||
{
|
||||
_s_taskExecuteSemaphore_F1ZCCOutstock.Release();
|
||||
}
|
||||
semaphoreSlim.Release();
|
||||
await InvokeGenPretaskExcute();
|
||||
}
|
||||
return Task.FromResult(true);
|
||||
|
||||
@@ -272,7 +272,6 @@ namespace Tnb.WarehouseMgr
|
||||
erpRequestData.Add("cdptvid","0001A11000000007GGO8");//部门先写死
|
||||
erpRequestData.Add("corpoid", erpOrg.corpoid);
|
||||
erpRequestData.Add("corpvid", erpOrg.corpvid);
|
||||
erpRequestData.Add("corpvid", erpOrg.corpvid);
|
||||
erpRequestData.Add("cotherwhid", wmsErpWarehouserelaHs.Find(x=>x.wms_warehousecode==wmsRawmatTransferoutstockD.warehouse_instock_code)?.erp_warehouseid ?? "");
|
||||
erpRequestData.Add("cwarehouseid", wmsErpWarehouserelaHs.Find(x=>x.erp_warehousecode==wmsRawmatTransferoutstockD.erp_wh_type)?.erp_warehouseid ?? "");
|
||||
erpRequestData.Add("creationtime", nowStr);
|
||||
|
||||
@@ -43,6 +43,7 @@ using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.ProductionMgr.Entities.Entity;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
|
||||
using System.Threading;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
@@ -782,8 +783,14 @@ namespace Tnb.WarehouseMgr
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Entities.Dto.Outputs.Result> DistributeBCK(MaterialTransferDistributeInput input)
|
||||
{
|
||||
SemaphoreSlim semaphoreSlimOutStock = null;
|
||||
SemaphoreSlim semaphoreSlimInStock = null;
|
||||
try
|
||||
{
|
||||
semaphoreSlimOutStock = _wareHouseService.GetSemaphore("outstock", WmsWareHouseConst.WAREHOUSE_BCK_ID);
|
||||
await semaphoreSlimOutStock.WaitAsync();
|
||||
semaphoreSlimInStock = _wareHouseService.GetSemaphore("instock", WmsWareHouseConst.WAREHOUSE_F2BCQ_ID);
|
||||
await semaphoreSlimInStock.WaitAsync();
|
||||
if (string.IsNullOrEmpty(input.source_id))
|
||||
{
|
||||
throw new AppFriendlyException("来源单据id不可为空", 500);
|
||||
@@ -813,14 +820,13 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
if (wmsMaterialTransfer.warehouse_outstock != WmsWareHouseConst.WAREHOUSE_BCK_ID)
|
||||
{
|
||||
throw new AppFriendlyException($@"转库单{wmsMaterialTransfer.bill_code}入库仓库不是四楼包材库,请检查!", HttpStatusCode.InternalServerError);
|
||||
throw new AppFriendlyException($@"转库单{wmsMaterialTransfer.bill_code}出库仓库不是四楼包材库,请检查!", HttpStatusCode.InternalServerError);
|
||||
}
|
||||
if (wmsMaterialTransfer.warehouse_instock != WmsWareHouseConst.WAREHOUSE_F2BCQ_ID)
|
||||
{
|
||||
throw new AppFriendlyException($@"转库单{wmsMaterialTransfer.bill_code}入库仓库不是二楼包材库,请检查!", HttpStatusCode.InternalServerError);
|
||||
}
|
||||
|
||||
await s_taskExecuteSemaphore.WaitAsync();
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
//入库取终点 //出库起点
|
||||
@@ -897,7 +903,8 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
finally
|
||||
{
|
||||
_ = s_taskExecuteSemaphore.Release();
|
||||
semaphoreSlimOutStock.Release();
|
||||
semaphoreSlimInStock.Release();
|
||||
InvokeGenPretaskExcute();
|
||||
}
|
||||
|
||||
@@ -1605,13 +1612,18 @@ namespace Tnb.WarehouseMgr
|
||||
// throw new AppFriendlyException($"此料架的库位为空!{input.carry_code}", 500);
|
||||
//}
|
||||
|
||||
if (string.IsNullOrEmpty(input.endlocation_id))
|
||||
if (string.IsNullOrEmpty(input.endlocation_code))
|
||||
{
|
||||
Logger.LogWarning($"【CallRackToProductionLine】终点库位不能为空!{input.endlocation_id}");
|
||||
throw new AppFriendlyException($"终点库位不能为空!{input.endlocation_id}", 500);
|
||||
Logger.LogWarning($"【CallRackToProductionLine】终点库位不能为空!{input.endlocation_code}");
|
||||
throw new AppFriendlyException($"终点库位不能为空!{input.endlocation_code}", 500);
|
||||
}
|
||||
|
||||
//BasLocation endlocation = _db.Queryable<BasLocation>().Where(r => r.location_code == wmsCarryH.work_station).First();
|
||||
BasLocation endlocation = await _db.Queryable<BasLocation>().Where(r => r.location_code == input.endlocation_code).FirstAsync();
|
||||
if (endlocation == null)
|
||||
{
|
||||
throw new AppFriendlyException($"终点库位{input.endlocation_code}在系统中不存在!", 500);
|
||||
}
|
||||
|
||||
WmsPretaskH wmsPretaskH = _db.Queryable<WmsPretaskH>().Where(r => r.carry_code == wmsCarryH.carry_code && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID).First();
|
||||
if (wmsPretaskH != null)
|
||||
@@ -1622,7 +1634,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
CommonCreatePretaskInput commonCreatePretaskInput = new CommonCreatePretaskInput();
|
||||
commonCreatePretaskInput.startlocation_id = wmsCarryH.location_id;
|
||||
commonCreatePretaskInput.endlocation_id = input.endlocation_id;
|
||||
commonCreatePretaskInput.endlocation_id = endlocation.id;
|
||||
commonCreatePretaskInput.carry_id = wmsCarryH.id;
|
||||
commonCreatePretaskInput.carry_code = wmsCarryH.carry_code;
|
||||
commonCreatePretaskInput.task_type = "";
|
||||
@@ -1681,11 +1693,11 @@ namespace Tnb.WarehouseMgr
|
||||
JArray jArray = new JArray();
|
||||
foreach (WmsCarryH wmsCarryH in wmsCarryHs)
|
||||
{
|
||||
if (wmsCarryH.carrystd_id != "26037267399717")
|
||||
{
|
||||
Logger.LogWarning($"【RackAndMatByWorkstation】工位{input.work_station}绑定的{wmsCarryH.carry_code}载具不是料架类型!请检查");
|
||||
continue;
|
||||
}
|
||||
//if (wmsCarryH.carrystd_id != "26037267399717")
|
||||
//{
|
||||
// Logger.LogWarning($"【RackAndMatByWorkstation】工位{input.work_station}绑定的{wmsCarryH.carry_code}载具不是料架类型!请检查");
|
||||
// continue;
|
||||
//}
|
||||
|
||||
var matCodes = _db.Queryable<WmsCarryD>()
|
||||
.InnerJoin<WmsCarryCode>((a, b) => a.membercarry_id == b.carry_id)
|
||||
|
||||
@@ -165,8 +165,11 @@ namespace Tnb.WarehouseMgr
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> OutsourcedPartsInstock(OutsourcedPartsInstockInput input)
|
||||
{
|
||||
SemaphoreSlim semaphoreSlim = null;
|
||||
try
|
||||
{
|
||||
semaphoreSlim = _wareHouseService.GetSemaphore("instock", WmsWareHouseConst.WAREHOUSE_CP_ID);
|
||||
await semaphoreSlim.WaitAsync();
|
||||
if (string.IsNullOrEmpty(input.carry_code))
|
||||
{
|
||||
throw new AppFriendlyException("载具编号不可为空", 500);
|
||||
@@ -193,10 +196,9 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
throw new AppFriendlyException("此成品调拨任务已完成,不允许重复提交", 500);
|
||||
}
|
||||
await s_taskExecuteSemaphore.WaitAsync();
|
||||
await _db.Ado.BeginTranAsync();
|
||||
//入库取终点 //出库起点
|
||||
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, Size = 1 };
|
||||
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID,Region_id = WmsWareHouseConst.REGION_CPOutstock_ID, Size = 1 };
|
||||
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
if (endLocations.Count == 0)
|
||||
{
|
||||
@@ -364,7 +366,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
finally
|
||||
{
|
||||
_ = s_taskExecuteSemaphore.Release();
|
||||
semaphoreSlim.Release();
|
||||
await InvokeGenPretaskExcute();
|
||||
}
|
||||
|
||||
@@ -379,6 +381,7 @@ namespace Tnb.WarehouseMgr
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> FinishproductOutstockSign(FinishproductOutstockSignInput input)
|
||||
{
|
||||
|
||||
Logger.LogInformation($"【FinishproductOutstockSign】载具签收 {input.carry_code}");
|
||||
if (string.IsNullOrEmpty(input.carry_code))
|
||||
{
|
||||
@@ -455,8 +458,8 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error($"【FinishproductOutstockSign】 {ex.Message}");
|
||||
Logger.Error($"【FinishproductOutstockSign】 {ex.StackTrace}");
|
||||
Logger.LogWarning($"【FinishproductOutstockSign】 {ex.Message}");
|
||||
Logger.LogWarning($"【FinishproductOutstockSign】 {ex.StackTrace}");
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
@@ -478,7 +481,28 @@ namespace Tnb.WarehouseMgr
|
||||
throw new AppFriendlyException("请选择区域", 500);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
OutStockStrategyQuery outStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, qty = 200, Region_id = WmsWareHouseConst.REGION_CPManualOutstock_ID, filter_carry_status = false };
|
||||
List<WmsCarryH> items = await _wareHouseService.OutStockStrategy(outStockStrategyInput);
|
||||
foreach (WmsCarryH wmsCarryH in items)
|
||||
{
|
||||
FinishproductOutstockSignInput signInput = new FinishproductOutstockSignInput();
|
||||
signInput.carry_code = wmsCarryH.carry_code;
|
||||
Entities.Dto.Outputs.Result result = await FinishproductOutstockSign(signInput);
|
||||
if (result.code != HttpStatusCode.OK)
|
||||
{
|
||||
throw new Exception($@"库位{wmsCarryH.location_code}中的载具{wmsCarryH.carry_code}签收失败! 错误信息:{result.msg}");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning($"【FinishproductOutstockSignAll】 {ex.Message}");
|
||||
Logger.LogWarning($"【FinishproductOutstockSignAll】 {ex.StackTrace}");
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,13 +58,11 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
private async Task<dynamic> PDAWmsEmptyOut(VisualDevModelDataCrInput input)
|
||||
{
|
||||
|
||||
if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_ZC_ID)
|
||||
await _s_taskExecuteSemaphore_F1ZCCOutstock.WaitAsync();
|
||||
else if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_HCC_ID)
|
||||
await _s_taskExecuteSemaphore_F2HCCOutstock.WaitAsync();
|
||||
SemaphoreSlim semaphoreSlim = null;
|
||||
try
|
||||
{
|
||||
semaphoreSlim = _wareHouseService.GetSemaphore("outstock", input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString());
|
||||
await semaphoreSlim.WaitAsync();
|
||||
Logger.Information("开始PDA空载具出库");
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
@@ -74,10 +72,15 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
//出库取起点,获取所有符合输入的载具规格的载具
|
||||
WmsEmptyOutstockH setQty = await _db.Queryable<WmsEmptyOutstockH>().FirstAsync(it => it.bill_code == input.data[nameof(WmsEmptyOutstockH.bill_code)].ToString());
|
||||
List<WmsCarryH>? carrys = await _db.Queryable<WmsCarryH>().LeftJoin<BasLocation>((a, b) => a.location_id == b.id)
|
||||
.Where((a, b) => a.carrystd_id == input.data[nameof(WmsEmptyOutstockH.carrystd_id)].ToString()
|
||||
&& a.carry_status == ((int)EnumCarryStatus.空闲).ToString() && a.is_lock == 0 && b.is_lock == 0 && b.is_type == ((int)EnumLocationType.存储库位).ToString())
|
||||
.ToListAsync();
|
||||
//出库取起点,获取所有符合输入的载具规格的载具
|
||||
OutStockStrategyQuery OutStockStrategyInput = new()
|
||||
{
|
||||
carrystd_id = input.data[nameof(OutStockStrategyQuery.carrystd_id)].ToString(),
|
||||
warehouse_id = input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString(),
|
||||
Size = 1
|
||||
};
|
||||
List<WmsCarryH>? carrys = await _wareHouseService.OutStockStrategy(OutStockStrategyInput);
|
||||
Logger.Information($"根据出库策略获取的载具数量:{carrys?.Count}");
|
||||
|
||||
WmsPointH sPoint = null!;
|
||||
WmsPointH ePoint = null!;
|
||||
@@ -90,139 +93,134 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
Logger.Information($"PDA空载具出库实际可出载具数量:{carrys.Count}");
|
||||
|
||||
if (int.Parse(input.data["qty"].ToString())> carrys.Count)
|
||||
if (carrys.Count < 1)
|
||||
{
|
||||
throw new AppFriendlyException($"实际可出空载具数量只有 {carrys.Count}", 500);
|
||||
throw new AppFriendlyException($"没有可以出库的空载具", 500);
|
||||
}
|
||||
|
||||
//根据每个载具的起始库位做路径运算
|
||||
for (i = 0; i < int.Parse(input.data["qty"].ToString()); i++)
|
||||
|
||||
if (carrys?.Count > 0)
|
||||
{
|
||||
|
||||
if (carrys?.Count > 0)
|
||||
{
|
||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carrys[i].location_id);
|
||||
}
|
||||
|
||||
if (sPoint != null && ePoint != null)
|
||||
{
|
||||
List<WmsPointH> points = new List<WmsPointH>();
|
||||
if (sPoint.area_code != ePoint.area_code)
|
||||
{
|
||||
points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
if (points.Count <= 2)
|
||||
{
|
||||
throw new AppFriendlyException($"sPoint {sPoint.point_code} ePoint{ePoint.point_code}该路径不存在", 500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points.Add(sPoint);
|
||||
points.Add(ePoint);
|
||||
}
|
||||
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTKPDA_ID, true);
|
||||
await _runService.Create(templateEntity, input);
|
||||
|
||||
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||
{
|
||||
WmsPointH? sPoint = it.FirstOrDefault();
|
||||
WmsPointH? ePoint = it.LastOrDefault();
|
||||
//生成预任务
|
||||
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_WMSEPTYOUTSTK_ID,
|
||||
task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID,
|
||||
carry_id = carrys![i].id,
|
||||
carry_code = carrys![i].carry_code,
|
||||
area_id = sPoint?.area_id!,
|
||||
area_code = it.Key,
|
||||
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!, _db);
|
||||
|
||||
}
|
||||
if (isOk)
|
||||
{
|
||||
//生成预任务上传输入
|
||||
GenPreTaskUpInput preTaskUpInput = new()
|
||||
{
|
||||
RquireId = input.data["ReturnIdentity"].ToString()!,
|
||||
CarryId = carrys![i].id,
|
||||
CarryStartLocationId = points.FirstOrDefault()!.location_id!,
|
||||
CarryStartLocationCode = points.FirstOrDefault()!.location_code!,
|
||||
LocationIds = points.Select(x => x.location_id).ToList()!
|
||||
};
|
||||
|
||||
//更新明细表
|
||||
WmsEmptyOutstockD wmsEmptyOutstockD = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = preTaskUpInput.RquireId,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
|
||||
location_id = ePoint!.location_id!,
|
||||
status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID,
|
||||
carry_id = carrys[i].id,
|
||||
carry_code = carrys[i].carry_code,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
_ = await _db.Insertable(wmsEmptyOutstockD)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
//生成操作记录表
|
||||
//WmsHandleH handleH = new()
|
||||
//{
|
||||
// org_id = _userManager.User.OrganizeId,
|
||||
// startlocation_id = carrys?[i].location_id!,
|
||||
// endlocation_id = ePoint!.location_id!,
|
||||
// bill_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||
// biz_type = input.data[nameof(WmsHandleH.biz_type)]?.ToString()!,
|
||||
// carry_id = input.data[nameof(WmsHandleH.carry_id)]?.ToString()!,
|
||||
// carry_code = input.data[nameof(WmsHandleH.carry_code)]?.ToString()!,
|
||||
// require_id = input.data["ReturnIdentity"].ToString(),
|
||||
// require_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||
// create_id = _userManager.UserId,
|
||||
// create_time = DateTime.Now
|
||||
//};
|
||||
//preTaskUpInput.PreTaskRecord = handleH;
|
||||
//根据空载具出库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, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
|
||||
it => new BasLocation { is_lock = 1 }, _db);
|
||||
}
|
||||
}
|
||||
|
||||
sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == carrys[i].location_id);
|
||||
}
|
||||
|
||||
if (sPoint != null && ePoint != null)
|
||||
{
|
||||
List<WmsPointH> points = new List<WmsPointH>();
|
||||
if (sPoint.area_code != ePoint.area_code)
|
||||
{
|
||||
points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);
|
||||
if (points.Count <= 2)
|
||||
{
|
||||
throw new AppFriendlyException($"sPoint {sPoint.point_code} ePoint{ePoint.point_code}该路径不存在", 500);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points.Add(sPoint);
|
||||
points.Add(ePoint);
|
||||
}
|
||||
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTKPDA_ID, true);
|
||||
await _runService.Create(templateEntity, input);
|
||||
|
||||
List<WmsPretaskH> preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
|
||||
{
|
||||
WmsPointH? sPoint = it.FirstOrDefault();
|
||||
WmsPointH? ePoint = it.LastOrDefault();
|
||||
//生成预任务
|
||||
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_WMSEPTYOUTSTK_ID,
|
||||
task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID,
|
||||
carry_id = carrys![i].id,
|
||||
carry_code = carrys![i].carry_code,
|
||||
area_id = sPoint?.area_id!,
|
||||
area_code = it.Key,
|
||||
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!, _db);
|
||||
|
||||
}
|
||||
if (isOk)
|
||||
{
|
||||
//生成预任务上传输入
|
||||
GenPreTaskUpInput preTaskUpInput = new()
|
||||
{
|
||||
RquireId = input.data["ReturnIdentity"].ToString()!,
|
||||
CarryId = carrys![i].id,
|
||||
CarryStartLocationId = points.FirstOrDefault()!.location_id!,
|
||||
CarryStartLocationCode = points.FirstOrDefault()!.location_code!,
|
||||
LocationIds = points.Select(x => x.location_id).ToList()!
|
||||
};
|
||||
|
||||
//更新明细表
|
||||
WmsEmptyOutstockD wmsEmptyOutstockD = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
bill_id = preTaskUpInput.RquireId,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID,
|
||||
location_id = ePoint!.location_id!,
|
||||
status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID,
|
||||
carry_id = carrys[i].id,
|
||||
carry_code = carrys[i].carry_code,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
_ = await _db.Insertable(wmsEmptyOutstockD)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
//生成操作记录表
|
||||
//WmsHandleH handleH = new()
|
||||
//{
|
||||
// org_id = _userManager.User.OrganizeId,
|
||||
// startlocation_id = carrys?[i].location_id!,
|
||||
// endlocation_id = ePoint!.location_id!,
|
||||
// bill_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||
// biz_type = input.data[nameof(WmsHandleH.biz_type)]?.ToString()!,
|
||||
// carry_id = input.data[nameof(WmsHandleH.carry_id)]?.ToString()!,
|
||||
// carry_code = input.data[nameof(WmsHandleH.carry_code)]?.ToString()!,
|
||||
// require_id = input.data["ReturnIdentity"].ToString(),
|
||||
// require_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!,
|
||||
// create_id = _userManager.UserId,
|
||||
// create_time = DateTime.Now
|
||||
//};
|
||||
//preTaskUpInput.PreTaskRecord = handleH;
|
||||
//根据空载具出库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, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode },
|
||||
it => new BasLocation { is_lock = 1 }, _db);
|
||||
}
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
@@ -235,11 +233,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_ZC_ID)
|
||||
_s_taskExecuteSemaphore_F1ZCCOutstock.Release();
|
||||
else if (input.data[nameof(OutStockStrategyQuery.warehouse_id)].ToString() == WmsWareHouseConst.WAREHOUSE_HCC_ID)
|
||||
_s_taskExecuteSemaphore_F2HCCOutstock.Release();
|
||||
|
||||
semaphoreSlim.Release();
|
||||
await InvokeGenPretaskExcute();
|
||||
}
|
||||
return Task.FromResult(true);
|
||||
|
||||
@@ -148,8 +148,11 @@ namespace Tnb.WarehouseMgr
|
||||
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> Distribute(SaleReleaseDistributeInput input)
|
||||
{
|
||||
Logger.LogInformation($"【Distribute】 销售出库下发");
|
||||
SemaphoreSlim semaphoreSlim = null;
|
||||
try
|
||||
{
|
||||
semaphoreSlim = _wareHouseService.GetSemaphore("outstock", WmsWareHouseConst.WAREHOUSE_CP_ID);
|
||||
await semaphoreSlim.WaitAsync();
|
||||
if (input.qty <= 0)
|
||||
{
|
||||
throw new AppFriendlyException("数量必须大于0", 500);
|
||||
@@ -160,7 +163,6 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
|
||||
WmsSaleD wmsOutstockD = await _db.Queryable<WmsSaleD>().FirstAsync(it => it.id == input.source_id);
|
||||
await s_taskExecuteSemaphore.WaitAsync();
|
||||
await _db.Ado.BeginTranAsync();
|
||||
//入库取终点 //出库起点
|
||||
OutStockStrategyQuery outStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, material_id = wmsOutstockD.material_id, qty = input.qty, code_batch = wmsOutstockD.code_batch, Region_id = WmsWareHouseConst.REGION_CPOutstock_ID };
|
||||
@@ -188,6 +190,13 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500);
|
||||
}
|
||||
|
||||
List<BasLocation> endLocations_temp = await _db.Queryable<BasLocation>().Where(r => r.region_id == WmsWareHouseConst.REGION_CPOutstockCache_ID && r.is_lock == 0 && r.is_use == "0").ToListAsync();
|
||||
|
||||
if (endLocations_temp.Count < items_pretask.Count)
|
||||
{
|
||||
throw new AppFriendlyException($"三楼发货时,没有可用的暂存库位可以使用,需要下发任务{items_pretask.Count}条,可用的暂存库位只有{endLocations_temp.Count}条", 500);
|
||||
}
|
||||
}
|
||||
//人工发货
|
||||
else
|
||||
@@ -400,7 +409,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
finally
|
||||
{
|
||||
_ = s_taskExecuteSemaphore.Release();
|
||||
semaphoreSlim.Release();
|
||||
await InvokeGenPretaskExcute();
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Tnb.WarehouseMgr
|
||||
warehouse_name = d.whname,
|
||||
material_name = f.name,
|
||||
material_specification = f.material_specification,
|
||||
container_no = f.container_no,
|
||||
container_no = f.material_standard,
|
||||
create_time = a.create_time,
|
||||
create_id = a.create_id,
|
||||
code_batch = a.code_batch,
|
||||
@@ -79,18 +79,6 @@ namespace Tnb.WarehouseMgr
|
||||
supplier_name = "",
|
||||
}, true).ToListAsync();
|
||||
|
||||
|
||||
string ssssss = _db.Queryable<WmsCarryCode>().InnerJoin<WmsCarryH>((a, b) => a.carry_id == b.id)
|
||||
.InnerJoin<BasLocation>((a, b, c) => b.location_id == c.id).InnerJoin<BasWarehouse>((a, b, c, d) => c.wh_id == d.id)
|
||||
.LeftJoin<WmsTempCode>((a, b, c, d, e) => e.barcode == a.barcode)
|
||||
.InnerJoin<BasMaterial>((a, b, c, d, e, f) => f.id == a.material_id)
|
||||
.LeftJoin<WmsPurchaseD>((a, b, c, d, e, f, g) => e.require_id == g.id)
|
||||
.LeftJoin<WmsPurchaseH>((a, b, c, d, e, f, g, h) => h.id == g.bill_id)
|
||||
.WhereIF(!string.IsNullOrEmpty(material_specification), (a, b, c, d, e, f) => f.material_specification.Contains(material_specification))
|
||||
.WhereIF(!string.IsNullOrEmpty(code_batch), (a, b, c, d, e, f) => a.code_batch.Contains(code_batch))
|
||||
.WhereIF(!string.IsNullOrEmpty(container_no), (a, b, c, d, e, f) => f.container_no.Contains(container_no))
|
||||
.WhereIF(!string.IsNullOrEmpty(material_code), (a, b, c, d, e, f) => f.code.Contains(material_code)).ToSqlString();
|
||||
|
||||
List<WmsCarryCode> carryCodes = await _db.Queryable<WmsCarryCode>().ToListAsync();
|
||||
var storeMap = items.DistinctBy(x => new { x.warehouse_id, x.material_id, x.code_batch }).ToDictionary(x => new { x.warehouse_id, x.material_id, x.code_batch }, x => x);
|
||||
|
||||
@@ -147,7 +135,7 @@ namespace Tnb.WarehouseMgr
|
||||
warehouse_name = d.whname,
|
||||
material_name = f.name,
|
||||
material_specification = f.material_specification,
|
||||
container_no = f.container_no,
|
||||
container_no = f.material_standard,
|
||||
create_time = a.create_time,
|
||||
create_id = a.create_id,
|
||||
code_batch = a.code_batch,
|
||||
|
||||
@@ -79,8 +79,11 @@ namespace Tnb.WarehouseMgr
|
||||
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> Distribute(WmsTransferOutstockInput input)
|
||||
{
|
||||
Logger.LogInformation($"【Distribute】 成品调拨出库下发");
|
||||
SemaphoreSlim semaphoreSlim = null;
|
||||
try
|
||||
{
|
||||
semaphoreSlim = _wareHouseService.GetSemaphore("outstock", WmsWareHouseConst.WAREHOUSE_CP_ID);
|
||||
await semaphoreSlim.WaitAsync();
|
||||
if (input.qty <= 0)
|
||||
{
|
||||
throw new AppFriendlyException("数量必须大于0", 500);
|
||||
@@ -91,7 +94,6 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
|
||||
WmsTransferOutstockD wmsOutstockD = await _db.Queryable<WmsTransferOutstockD>().FirstAsync(it => it.id == input.source_id);
|
||||
await s_taskExecuteSemaphore.WaitAsync();
|
||||
await _db.Ado.BeginTranAsync();
|
||||
//入库取终点 //出库起点
|
||||
OutStockStrategyQuery outStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, material_id = wmsOutstockD.material_id, qty = input.qty, code_batch = wmsOutstockD.pi_code, Region_id = WmsWareHouseConst.REGION_CPOutstock_ID };
|
||||
@@ -149,6 +151,12 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500);
|
||||
}
|
||||
List<BasLocation> endLocations_temp = await _db.Queryable<BasLocation>().Where(r => r.region_id == WmsWareHouseConst.REGION_CPOutstockCache_ID && r.is_lock == 0 && r.is_use == "0").ToListAsync();
|
||||
|
||||
if (endLocations_temp.Count < items_pretask.Count)
|
||||
{
|
||||
throw new AppFriendlyException($"三楼发货时,没有可用的暂存库位可以使用,需要下发任务{items_pretask.Count}条,可用的暂存库位只有{endLocations_temp.Count}条", 500);
|
||||
}
|
||||
}
|
||||
//人工发货
|
||||
else
|
||||
@@ -327,7 +335,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
finally
|
||||
{
|
||||
_ = s_taskExecuteSemaphore.Release();
|
||||
semaphoreSlim.Release();
|
||||
await InvokeGenPretaskExcute();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user