销售发货接口、原材料仓优化调整、日志优化
This commit is contained in:
@@ -391,9 +391,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
//扫码入库
|
||||
private async void ScanInStock(object? state)
|
||||
{
|
||||
if (s_taskScan.CurrentCount == 0)
|
||||
if (_wareHouseService.s_taskExecuteSemaphore_YCLInstock.CurrentCount == 0)
|
||||
return;
|
||||
await s_taskScan.WaitAsync();
|
||||
await _wareHouseService.s_taskExecuteSemaphore_YCLInstock.WaitAsync();
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
try
|
||||
@@ -485,7 +485,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_taskScan.Release();
|
||||
_wareHouseService.s_taskExecuteSemaphore_YCLInstock.Release();
|
||||
stopwatch.Stop();
|
||||
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行ScanInStock {stopwatch.ElapsedMilliseconds} ms");
|
||||
LoggerTimer.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行ScanInStock {stopwatch.ElapsedMilliseconds} ms");
|
||||
@@ -634,9 +634,13 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
/// <param name="state"></param>
|
||||
private async void YCLInternalTransfer(object? state)
|
||||
{
|
||||
if (s_taskYCLInternalTransfer.CurrentCount == 0)
|
||||
if (_wareHouseService.s_taskExecuteSemaphore_YCLInstock.CurrentCount == 0)
|
||||
return;
|
||||
await s_taskYCLInternalTransfer.WaitAsync();
|
||||
if (_wareHouseService.s_taskExecuteSemaphore_YCLOutstock.CurrentCount == 0)
|
||||
return;
|
||||
|
||||
await _wareHouseService.s_taskExecuteSemaphore_YCLInstock.WaitAsync();
|
||||
await _wareHouseService.s_taskExecuteSemaphore_YCLOutstock.WaitAsync();
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
try
|
||||
@@ -650,7 +654,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
warehouse_id = WmsWareHouseConst.WAREHOUSE_YCL_ID,
|
||||
Region_id = WmsWareHouseConst.REGION_YCLCache_ID,
|
||||
AvoidBusyPassage = true,
|
||||
Size = 5,
|
||||
Size = 76,
|
||||
filter_carry_status = false
|
||||
};
|
||||
List<WmsCarryH> items = await _wareHouseService.OutStockStrategy(outStockStrategyInput);
|
||||
@@ -704,7 +708,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_taskYCLInternalTransfer.Release();
|
||||
_wareHouseService.s_taskExecuteSemaphore_YCLInstock.Release();
|
||||
_wareHouseService.s_taskExecuteSemaphore_YCLOutstock.Release();
|
||||
|
||||
stopwatch.Stop();
|
||||
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行YCLInternalTransfer {stopwatch.ElapsedMilliseconds} ms");
|
||||
LoggerTimer.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行YCLInternalTransfer {stopwatch.ElapsedMilliseconds} ms");
|
||||
@@ -716,9 +722,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
/// </summary>
|
||||
private async void YCLGLDPJInstock(object? state)
|
||||
{
|
||||
if (s_taskYCLGLDPJInstock.CurrentCount == 0)
|
||||
if (_wareHouseService.s_taskExecuteSemaphore_YCLInstock.CurrentCount == 0)
|
||||
return;
|
||||
await s_taskYCLGLDPJInstock.WaitAsync();
|
||||
await _wareHouseService.s_taskExecuteSemaphore_YCLInstock.WaitAsync();
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
try
|
||||
@@ -752,11 +758,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
continue;
|
||||
}
|
||||
|
||||
// 找到未锁定且未占用的库位
|
||||
var endLocations = db_YCLGLDPJInstocktimer.Queryable<BasLocation>()
|
||||
.Where(a => a.is_lock == 0 && a.is_use == "0" && a.wh_id == WmsWareHouseConst.WAREHOUSE_YCL_ID && a.location_code.Contains("YCL-") && a.is_type == "0");
|
||||
|
||||
LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 sql {endLocations.ToSqlString()}");
|
||||
// 找到未锁定且未占用的库位
|
||||
|
||||
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = "1", Size = 1, AvoidBusyPassage = true, Region_id = WmsWareHouseConst.REGION_Purchase_ID };
|
||||
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
|
||||
if (endLocations.Count() == 0)
|
||||
{
|
||||
@@ -802,7 +808,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_taskYCLGLDPJInstock.Release();
|
||||
_wareHouseService.s_taskExecuteSemaphore_YCLInstock.Release();
|
||||
stopwatch.Stop();
|
||||
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行YCLGLDPJInstock {stopwatch.ElapsedMilliseconds} ms");
|
||||
LoggerTimer.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行YCLGLDPJInstock {stopwatch.ElapsedMilliseconds} ms");
|
||||
@@ -814,9 +820,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
/// </summary>
|
||||
private async void YCLWXDPJInstock(object? state)
|
||||
{
|
||||
if (s_taskYCLWXDPJInstock.CurrentCount == 0)
|
||||
if (_wareHouseService.s_taskExecuteSemaphore_YCLInstock.CurrentCount == 0)
|
||||
return;
|
||||
await s_taskYCLWXDPJInstock.WaitAsync();
|
||||
await _wareHouseService.s_taskExecuteSemaphore_YCLInstock.WaitAsync();
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
try
|
||||
@@ -849,10 +855,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
}
|
||||
|
||||
// 找到未锁定且未占用的库位
|
||||
var endLocations = db_YCLWXDPJInstocktimer.Queryable<BasLocation>()
|
||||
.Where(a => a.is_lock == 0 && a.is_use == "0" && a.wh_id == WmsWareHouseConst.WAREHOUSE_YCL_ID && a.location_code.Contains("YCL-") && a.is_type == "0");
|
||||
|
||||
LoggerYCLGLDPJInstock.LogInformation($"【YCLWXDPJInstock】 sql {endLocations.ToSqlString()}");
|
||||
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = "1", Size = 1, AvoidBusyPassage = true, Region_id = WmsWareHouseConst.REGION_Purchase_ID };
|
||||
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
|
||||
if (endLocations.Count() == 0)
|
||||
{
|
||||
@@ -897,7 +901,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_taskYCLWXDPJInstock.Release();
|
||||
_wareHouseService.s_taskExecuteSemaphore_YCLInstock.Release();
|
||||
stopwatch.Stop();
|
||||
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行YCLWXDPJInstock {stopwatch.ElapsedMilliseconds} ms");
|
||||
LoggerTimer.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行YCLWXDPJInstock {stopwatch.ElapsedMilliseconds} ms");
|
||||
@@ -2459,41 +2463,6 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
//Readtimer = new Timer(GetRedisData, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
|
||||
CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
SSXcodetimer = new Timer(SSXcode, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
// 八工位缓存区补充空托盘
|
||||
BGWCarrySupplementtimer = new Timer(BGWCarrySupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
|
||||
// 供料叠盘机空托盘自动入库
|
||||
YCLGLDPJInstocktimer = new Timer(YCLGLDPJInstock, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
|
||||
// 外协叠盘机空托盘自动入库
|
||||
//YCLWXDPJInstocktimer = new Timer(YCLWXDPJInstock, null, TimeSpan.Zero, TimeSpan.FromSeconds(100000));
|
||||
|
||||
// 二楼上升降机
|
||||
Floor2UpMachinecodetimer = new Timer(Floor2UpMachinecode, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
|
||||
// 二楼料架配送
|
||||
Floor2timer送空托到上升降区 = new Timer(送空托到上升降区, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
Floor2timer送满托到下升降区 = new Timer(送满托到下升降区, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
Floor2timer移走上升降区未生成预任务且满托的料架 = new Timer(移走上升降区未生成预任务且满托的料架, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
Floor2timer移走下升降区未生成预任务且空托的料架 = new Timer(移走下升降区未生成预任务且空托的料架, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
|
||||
GenTaskExecutetimer = new Timer(GenTaskExecute, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
|
||||
// 停用
|
||||
//PackOutstockServicetimer = new Timer(PackOutstockService, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
|
||||
|
||||
ElevatorTaskExceptionHandleThread = new Thread(ElevatorTaskExceptionHandle);
|
||||
ElevatorTaskExceptionHandleThread.Start();
|
||||
|
||||
Floor4DMJ2MJXtimer = new Timer(Floor4DMJ2MJX, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
Floor4MJX2MJCtimer = new Timer(Floor4MJX2MJC, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
Floor4DMC2CPKtimer = new Timer(Floor4DMC2CPK, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
|
||||
F2KTPsupplementtimer = new Timer(F2KTPsupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));//Readtimer = new Timer(GetRedisData, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
|
||||
CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
|
||||
Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
|
||||
SSXcodetimer = new Timer(SSXcode, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
|
||||
@@ -2504,7 +2473,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
YCLGLDPJInstocktimer = new Timer(YCLGLDPJInstock, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
|
||||
// 外协叠盘机空托盘自动入库
|
||||
//YCLWXDPJInstocktimer = new Timer(YCLWXDPJInstock, null, TimeSpan.Zero, TimeSpan.FromSeconds(100000));
|
||||
YCLWXDPJInstocktimer = new Timer(YCLWXDPJInstock, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
|
||||
// 二楼上升降机
|
||||
Floor2UpMachinecodetimer = new Timer(Floor2UpMachinecode, null, TimeSpan.Zero, TimeSpan.FromSeconds(20));
|
||||
@@ -2528,7 +2497,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
Floor4DMC2CPKtimer = new Timer(Floor4DMC2CPK, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
|
||||
F2KTPsupplementtimer = new Timer(F2KTPsupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
YCLInternalTransfertimer = new Timer(YCLInternalTransfer, null, TimeSpan.Zero, TimeSpan.FromSeconds(180));
|
||||
YCLInternalTransfertimer = new Timer(YCLInternalTransfer, null, TimeSpan.Zero, TimeSpan.FromSeconds(10800));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs
|
||||
{
|
||||
public class SaleShippingInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 销售发货单号
|
||||
/// </summary>
|
||||
public string? bill_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据类型
|
||||
/// </summary>
|
||||
public string? bill_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据状态
|
||||
/// </summary>
|
||||
public string? bill_status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出库仓库编号
|
||||
/// </summary>
|
||||
public string? warehouse_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户编码
|
||||
/// </summary>
|
||||
public string? customer_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户名称
|
||||
/// </summary>
|
||||
public string? customer_name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 供货日期
|
||||
/// </summary>
|
||||
public DateTime? ship_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主表主键
|
||||
/// </summary>
|
||||
public string erp_pk { get; set; }
|
||||
|
||||
public List<SaleShippingDetail> details { get; set; }
|
||||
}
|
||||
public class SaleShippingDetail
|
||||
{
|
||||
/// <summary>
|
||||
/// 行号
|
||||
/// </summary>
|
||||
public string? lineno { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料代码
|
||||
/// </summary>
|
||||
public string? material_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位代码
|
||||
/// </summary>
|
||||
public string? unit_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 批号
|
||||
/// </summary>
|
||||
public string? code_batch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发货数量
|
||||
/// </summary>
|
||||
public decimal? sale_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子表主键
|
||||
/// </summary>
|
||||
public string erp_line_pk { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ namespace Tnb.WarehouseMgr.Entities.Dto
|
||||
public int layers { get; set; }
|
||||
public string carry_code { get; set; }
|
||||
public string material_code { get; set; }
|
||||
public string code_batch { get; set; }
|
||||
public decimal num { get; set; }
|
||||
}
|
||||
public class ZsjOutput
|
||||
|
||||
@@ -99,5 +99,5 @@ public partial class WmsElevatorH : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 占用任务
|
||||
/// </summary>
|
||||
public int use_tasks { get; set; }
|
||||
public string use_tasks { get; set; }
|
||||
}
|
||||
|
||||
@@ -91,4 +91,11 @@ public partial class WmsSaleD : BaseEntity<string>
|
||||
/// 箱号
|
||||
/// </summary>
|
||||
public string? container_no { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// erp_line_pk
|
||||
/// </summary>
|
||||
public string? erp_line_pk { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -145,4 +145,14 @@ public partial class WmsSaleH : BaseEntity<string>, IPurchaseAndSaleAuitEntity
|
||||
/// </summary>
|
||||
public int? audit_status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// erp_pk
|
||||
/// </summary>
|
||||
public string? erp_pk { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// erp_bill_code
|
||||
/// </summary>
|
||||
public string? erp_bill_code { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,15 @@ namespace Tnb.WarehouseMgr.Interfaces
|
||||
/// </summary>
|
||||
public interface IWareHouseService
|
||||
{
|
||||
/// <summary>
|
||||
/// 原材料入库
|
||||
/// </summary>
|
||||
SemaphoreSlim s_taskExecuteSemaphore_YCLInstock { get; }
|
||||
/// <summary>
|
||||
/// 原材料出库
|
||||
/// </summary>
|
||||
SemaphoreSlim s_taskExecuteSemaphore_YCLOutstock { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库策略
|
||||
/// </summary>
|
||||
|
||||
@@ -47,6 +47,11 @@ namespace Tnb.WarehouseMgr
|
||||
public static SemaphoreSlim s_taskExecuteSemaphore = new(1);
|
||||
public static SemaphoreSlim s_elevatorStatusSemaphore = new(1);
|
||||
|
||||
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_YCLInstock = new(1);
|
||||
public static SemaphoreSlim _s_taskExecuteSemaphore_YCLOutstock = new(1);
|
||||
|
||||
|
||||
protected static Dictionary<string, int> _s_eleUseStatusDic;
|
||||
|
||||
protected IEventPublisher? EventPublisher { set; get; }
|
||||
|
||||
@@ -477,16 +477,43 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
else
|
||||
{
|
||||
// 排除电梯任务 其他任务取消时自动解锁终点库位
|
||||
int unlockRow = await _db.Updateable<BasLocation>().SetColumns(r => r.is_lock == 0).Where(r => r.location_code == wmsDistaskH.endlocation_code).ExecuteCommandAsync();
|
||||
if (unlockRow > 0)
|
||||
// 排除电梯任务 其他任务取消时自动解锁起点和终点库位
|
||||
|
||||
//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}");
|
||||
Logger.Information($"成功解锁终点库位{wmsDistaskH.endlocation_code}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Information($"未成功解锁库位{wmsDistaskH.endlocation_code}");
|
||||
Logger.Information($"未成功解锁终点库位{wmsDistaskH.endlocation_code}");
|
||||
}
|
||||
|
||||
int unlockCarryRow = await _db.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH
|
||||
{
|
||||
is_lock = 0,
|
||||
//location_id = wmsDistaskH.startlocation_code.Contains("BGWRKYCL0") ? WmsWareHouseConst.LOCATION_YCLBGWDRK : r.location_id,
|
||||
//location_code = wmsDistaskH.startlocation_code.Contains("BGWRKYCL0") ? "YCLBGWDRK" : r.location_code
|
||||
}).Where(r => r.carry_code == wmsDistaskH.carry_code).ExecuteCommandAsync();
|
||||
if (unlockCarryRow > 0)
|
||||
{
|
||||
Logger.Information($"成功解锁载具{wmsDistaskH.carry_code}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Information($"未成功解锁载具{wmsDistaskH.carry_code}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,6 +542,58 @@ namespace Tnb.WarehouseMgr
|
||||
if (row > 0)
|
||||
{
|
||||
List<string> wmsDistaskHCodes = _db.Queryable<WmsDistaskH>().Where(P => P.bill_code.Contains(input.taskChainCode)).Select(r => r.pretask_code).ToList();
|
||||
List<WmsDistaskH> wmsDistaskHs = _db.Queryable<WmsDistaskH>().Where(P => P.bill_code.Contains(input.taskChainCode)).ToList();
|
||||
|
||||
foreach (WmsDistaskH wmsDistaskH in wmsDistaskHs)
|
||||
{
|
||||
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}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 排除电梯任务 其他任务取消时自动解锁起点和终点库位
|
||||
|
||||
//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}");
|
||||
}
|
||||
|
||||
int unlockCarryRow = await _db.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH
|
||||
{
|
||||
is_lock = 0,
|
||||
//location_id = wmsDistaskH.startlocation_code.Contains("BGWRKYCL0") ? WmsWareHouseConst.LOCATION_YCLBGWDRK : wmsDistaskH.startlocation_id,
|
||||
//location_code = wmsDistaskH.startlocation_code.Contains("BGWRKYCL0") ? "YCLBGWDRK" : wmsDistaskH.startlocation_code
|
||||
}).Where(r => r.carry_code == wmsDistaskH.carry_code).ExecuteCommandAsync();
|
||||
if (unlockCarryRow > 0)
|
||||
{
|
||||
Logger.Information($"成功解锁载具{wmsDistaskH.carry_code}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Information($"未成功解锁载具{wmsDistaskH.carry_code}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
await _db.Updateable<WmsPretaskH>().SetColumns(r => new WmsPretaskH
|
||||
{
|
||||
|
||||
@@ -670,6 +670,130 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销售发货单
|
||||
/// </summary>
|
||||
[HttpPost, NonUnify, AllowAnonymous]
|
||||
public async Task<Entities.Dto.Outputs.Result> SaleShipping(SaleShippingInput input)
|
||||
{
|
||||
|
||||
|
||||
LoggerErp2Mes.LogInformation($"【SaleShipping】ERP传入数据:{JsonConvert.SerializeObject(input)}");
|
||||
var db = _repository.AsSugarClient();
|
||||
|
||||
if (string.IsNullOrEmpty(input.erp_pk))
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($"【SaleShipping】主表主键不能为空!");
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, $"主表主键不能为空!");
|
||||
}
|
||||
|
||||
int count_erp_line_pk = input.details.Where(r => string.IsNullOrEmpty(r.erp_line_pk)).Count();
|
||||
if (count_erp_line_pk > 0)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【SaleShipping】子表主键不能为空!");
|
||||
throw new AppFriendlyException($@"子表主键不能为空!", 500);
|
||||
}
|
||||
|
||||
var wmsSaleShippingsDistinct = input.details.Select(r => new
|
||||
{
|
||||
material_id = r.material_code,
|
||||
code_batch = r.code_batch,
|
||||
}).Distinct();
|
||||
if (wmsSaleShippingsDistinct.Count() < input.details.Count)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【SaleShipping】表体存在物料和批号重复的明细!");
|
||||
throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500);
|
||||
}
|
||||
|
||||
BasWarehouse warehouse_outstock = await db.Queryable<BasWarehouse>().Where(r => r.whcode == input.warehouse_code).FirstAsync();
|
||||
if (warehouse_outstock == null)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($"【MaterialTransfer】无法查询到出库仓库{input.warehouse_code}的档案记录!");
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, $"无法查询到出库仓库{input.warehouse_code}的档案记录!");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await db.Ado.BeginTranAsync();
|
||||
WmsSaleH wmsSaleH = new WmsSaleH();
|
||||
string Code = await _billRuleService.GetBillNumber("WmsSale");
|
||||
|
||||
wmsSaleH.bill_code = Code;
|
||||
wmsSaleH.erp_bill_code = input.bill_code;
|
||||
wmsSaleH.bill_type = "25103439022357";//销售出库单
|
||||
wmsSaleH.status = WmsWareHouseConst.BILLSTATUS_ADD_ID;
|
||||
wmsSaleH.warehouse_id = warehouse_outstock.id;
|
||||
wmsSaleH.customer_code = input.customer_code;
|
||||
var customer = await db.Queryable<BasCustomer>().Where(p => p.customer_code == input.customer_code).FirstAsync();
|
||||
if (customer != null)
|
||||
{
|
||||
wmsSaleH.customer_id = customer.id;
|
||||
wmsSaleH.customer_name = customer.customer_name;
|
||||
}
|
||||
|
||||
wmsSaleH.ship_date = input.ship_date.Value;
|
||||
wmsSaleH.erp_pk = input.erp_pk;
|
||||
wmsSaleH.create_id = WmsWareHouseConst.ErpUserId;
|
||||
wmsSaleH.create_time = DateTime.Now;
|
||||
|
||||
await db.Insertable(wmsSaleH).ExecuteCommandAsync();
|
||||
|
||||
|
||||
List<WmsSaleD> wmsSaleDs = new List<WmsSaleD>();
|
||||
foreach (var detail in input.details)
|
||||
{
|
||||
WmsSaleD wmsSaleD = new WmsSaleD();
|
||||
|
||||
wmsSaleD.bill_id = wmsSaleH.id;
|
||||
wmsSaleD.material_code = detail.material_code;
|
||||
wmsSaleD.purchase_qty = detail.sale_qty.Value;
|
||||
wmsSaleD.code_batch = detail.code_batch;
|
||||
wmsSaleD.erp_line_pk = detail.erp_line_pk;
|
||||
wmsSaleD.create_id = WmsWareHouseConst.ErpUserId;
|
||||
wmsSaleD.create_time = DateTime.Now;
|
||||
|
||||
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)
|
||||
{
|
||||
wmsSaleD.unit_id = erpExtendField.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【MaterialTransfer】表体明细中单位{detail.unit_code}在wms系统中未找到!");
|
||||
throw new AppFriendlyException($@"表体明细中单位{detail.unit_code}在wms系统中未找到!", 500);
|
||||
}
|
||||
|
||||
var material = await db.Queryable<BasMaterial>().Where(p => p.code == detail.material_code).FirstAsync();
|
||||
if (material != null)
|
||||
{
|
||||
wmsSaleD.material_id = material.id;
|
||||
wmsSaleD.material_name = material.name;
|
||||
wmsSaleD.material_specification = material.material_specification;
|
||||
}
|
||||
|
||||
wmsSaleDs.Add(wmsSaleD);
|
||||
}
|
||||
|
||||
await db.Insertable(wmsSaleDs).ExecuteCommandAsync();
|
||||
|
||||
await db.Ado.CommitTranAsync();
|
||||
|
||||
LoggerErp2Mes.LogInformation($"【SaleShipping】成功生成单据:{Code}");
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerErp2Mes.LogError($"【SaleShipping】{ex.Message}");
|
||||
LoggerErp2Mes.LogError($"【SaleShipping】{ex.StackTrace}");
|
||||
await db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected Task<Entities.Dto.Outputs.Result> ToApiResult(HttpStatusCode statusCode, string msg)
|
||||
{
|
||||
Entities.Dto.Outputs.Result result = new()
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace Tnb.WarehouseMgr
|
||||
public async Task<dynamic> GetYCLlocation()
|
||||
{
|
||||
List<List<LocationOutput>> LocationOutputss=new List<List<LocationOutput>>();
|
||||
var list =await _db.Queryable<BasLocation>().Where(p=> p.wh_id == "1" && p.region_id== "26125793924133"&& p.is_type == "0" && p.location_code.Length==9).OrderBy(p=>p.location_code).ToListAsync();
|
||||
var list =await _db.Queryable<BasLocation>().Where(p=> p.wh_id == "1" && p.is_type == "0" && !p.location_code.Contains("-3")).OrderBy(p=>p.location_code).ToListAsync();
|
||||
var carrys=await _db.Queryable<WmsCarryH>().ToListAsync();
|
||||
var carrycodes=await _db.Queryable<WmsCarryCode>().ToListAsync();
|
||||
var lastdata=string.Empty;
|
||||
@@ -187,7 +187,7 @@ namespace Tnb.WarehouseMgr
|
||||
LocationOutputs = new List<LocationOutput>();
|
||||
}
|
||||
LocationOutput locationOutput = new LocationOutput();
|
||||
locationOutput.location_code = data.location_code;
|
||||
locationOutput.location_code = data.location_code.Replace("YCL-", "");
|
||||
locationOutput.layers = data.layers;
|
||||
locationOutput.type = 0;
|
||||
if (carrys.Where(p => p.location_id == data.id).Any())
|
||||
@@ -200,11 +200,16 @@ namespace Tnb.WarehouseMgr
|
||||
var carrycode = carrycodes.Where(p => p.carry_id == carry.id).First();
|
||||
locationOutput.type = 2;
|
||||
locationOutput.material_code = carrycode.material_code;
|
||||
locationOutput.code_batch = carrycode.code_batch;
|
||||
locationOutput.num = carrycode.codeqty;
|
||||
}
|
||||
}
|
||||
lastdata = data.location_code;
|
||||
LocationOutputs.Add(locationOutput);
|
||||
|
||||
// 。。。。。。
|
||||
if (data.location_code == list[list.Count - 1].location_code)
|
||||
LocationOutputss.Add(LocationOutputs);
|
||||
}
|
||||
return LocationOutputss;
|
||||
}
|
||||
|
||||
@@ -87,6 +87,16 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
public Func<string, int, Task> AddUnExecuteTask { get; set; }
|
||||
|
||||
|
||||
public SemaphoreSlim s_taskExecuteSemaphore_YCLInstock
|
||||
{
|
||||
get { return _s_taskExecuteSemaphore_YCLInstock; }
|
||||
}
|
||||
|
||||
public SemaphoreSlim s_taskExecuteSemaphore_YCLOutstock
|
||||
{
|
||||
get { return _s_taskExecuteSemaphore_YCLOutstock; }
|
||||
}
|
||||
|
||||
public WareHouseService(ISqlSugarRepository<WmsInstockH> repository, IDictionaryDataService dictionaryDataService, StackExRedisHelper redisData,
|
||||
IBillRullService billRullService, IUserManager userManager, ICacheManager cacheManager, IElevatorControlService elevatorControlService,
|
||||
|
||||
@@ -165,6 +165,17 @@ namespace Tnb.WarehouseMgr
|
||||
try
|
||||
{
|
||||
WmsCarryH? carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carrycode);
|
||||
if (carry == null)
|
||||
{
|
||||
throw new Exception($"托盘{input.carrycode}不存在!");
|
||||
}
|
||||
|
||||
var _WmsCarryCode = _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carry.id).OrderByDescending(it => it.id).First();
|
||||
if (_WmsCarryCode != null)
|
||||
{
|
||||
throw new Exception($"托盘{input.carrycode}已绑定物料!");
|
||||
}
|
||||
|
||||
List<WmsCarryCode> WmsCarryCodes = new List<WmsCarryCode>();
|
||||
foreach (var detail in input.details)
|
||||
{
|
||||
@@ -183,7 +194,8 @@ namespace Tnb.WarehouseMgr
|
||||
await _db.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH
|
||||
{
|
||||
location_id = WmsWareHouseConst.LOCATION_YCLBGWDRK,
|
||||
location_code = "YCLBGWDRK"
|
||||
location_code = "YCLBGWDRK",
|
||||
carry_status = "1"
|
||||
}).Where(r => r.id == carry.id).ExecuteCommandAsync();
|
||||
if (rows == 0)
|
||||
{
|
||||
@@ -194,7 +206,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
Logger.LogError(ex.Message);
|
||||
Logger.LogError(ex.StackTrace);
|
||||
throw new AppFriendlyException($"绑定失败(1.可能是存在已被绑定的条码 2.存在其他与此载具编号相同的载具 3.存在字段传了空值) {ex.Message}", 500);
|
||||
throw new AppFriendlyException($"绑定失败(1.可能是存在已被绑定的条码 2.系统中存在其他与此托盘编号相同的托盘 3.存在字段传了空值) {ex.Message}", 500);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Tnb.WarehouseMgr
|
||||
&& ((!string.IsNullOrEmpty(b.carry_code) && b.carry_status != "0" && b.carry_status != "6") || string.IsNullOrEmpty(b.carry_code)))
|
||||
.WhereIF(!string.IsNullOrEmpty(warehouse_id), (a, b, c, d) => c.id == warehouse_id)
|
||||
.WhereIF(!string.IsNullOrEmpty(carry_code), (a, b, c, d) => b.carry_code.Contains(carry_code))
|
||||
.WhereIF(!string.IsNullOrEmpty(material_code), (a, b, c, d, e, f) => f.code.Contains(material_code))
|
||||
.WhereIF(!string.IsNullOrEmpty(material_code), (a, b, c, d, e, f) => e.material_code.Contains(material_code))
|
||||
.OrderByDescending((a, b, c, d, e, f) => b.carry_code)
|
||||
.Select((a, b, c, d, e, f) => new WmsCarryStockReport
|
||||
{
|
||||
@@ -83,9 +83,9 @@ namespace Tnb.WarehouseMgr
|
||||
creator = e.create_id,
|
||||
bind_time = e.create_time != null ? e.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
|
||||
})
|
||||
.OrderBy((a) => a.location_code)
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
// 料架
|
||||
List<WmsCarryStockReport> items_LJ = await _db.Queryable<BasLocation>()
|
||||
.LeftJoin<WmsCarryH>((a, b) => b.location_id == a.id)
|
||||
@@ -123,14 +123,15 @@ namespace Tnb.WarehouseMgr
|
||||
creator = f.create_id,
|
||||
bind_time = f.create_time != null ? f.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
|
||||
})
|
||||
.OrderBy((a) => a.location_code)
|
||||
.ToListAsync();
|
||||
|
||||
items.AddRange(items_LJ);
|
||||
|
||||
// d.carrystd_name != "料架"
|
||||
var storeMap = items.DistinctBy(x => new { x.carry_id }).ToDictionary(x => new { x.carry_id }, x => x);
|
||||
var storeMap = items.DistinctBy(x => new { x.carry_id,x.location_code }).ToDictionary(x => new { x.carry_id, x.location_code }, x => x);
|
||||
|
||||
IEnumerable<WmsCarryStockReportH> result = items.GroupBy(g => new { g.carry_id }).Select(itGroup =>
|
||||
IEnumerable<WmsCarryStockReportH> result = items.GroupBy(g => new { g.carry_id, g.location_code }).Select(itGroup =>
|
||||
{
|
||||
_ = storeMap.TryGetValue(itGroup.Key, out WmsCarryStockReport? report);
|
||||
WmsCarryStockReportH stockReport = report.Adapt<WmsCarryStockReportH>();
|
||||
|
||||
@@ -307,6 +307,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
try
|
||||
{
|
||||
await _s_taskExecuteSemaphore_YCLOutstock.WaitAsync();
|
||||
if (string.IsNullOrEmpty(input.source_id))
|
||||
{
|
||||
throw new AppFriendlyException("来源单据id不可为空", 500);
|
||||
@@ -327,7 +328,6 @@ namespace Tnb.WarehouseMgr
|
||||
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);
|
||||
|
||||
await s_taskExecuteSemaphore.WaitAsync();
|
||||
if (wmsMaterialTransferD.yxfqty >= wmsMaterialTransferD.qty)
|
||||
{
|
||||
throw new AppFriendlyException("已下发数量已达到转库数量", 500);
|
||||
@@ -430,7 +430,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
finally
|
||||
{
|
||||
_ = s_taskExecuteSemaphore.Release();
|
||||
_ = _s_taskExecuteSemaphore_YCLOutstock.Release();
|
||||
InvokeGenPretaskExcute();
|
||||
}
|
||||
|
||||
@@ -1446,7 +1446,7 @@ namespace Tnb.WarehouseMgr
|
||||
throw new AppFriendlyException($"载具{input.carry_code}当前所在库位不是三工位!", 500);
|
||||
}
|
||||
|
||||
await s_taskExecuteSemaphore.WaitAsync();
|
||||
await _s_taskExecuteSemaphore_YCLInstock.WaitAsync();
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
|
||||
@@ -1514,7 +1514,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
finally
|
||||
{
|
||||
_ = s_taskExecuteSemaphore.Release();
|
||||
_ = _s_taskExecuteSemaphore_YCLInstock.Release();
|
||||
InvokeGenPretaskExcute();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user