电梯逻辑变更 erp同步调整 生成条码变更等
This commit is contained in:
@@ -11,6 +11,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells.Charts;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF;
|
||||
using JNPF.Common.Cache;
|
||||
using JNPF.Common.Core.Manager;
|
||||
@@ -28,6 +29,7 @@ using NetTaste;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Npgsql;
|
||||
using NPOI.HPSF;
|
||||
using NPOI.OpenXmlFormats;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Asn1.X509.Qualified;
|
||||
@@ -89,15 +91,15 @@ namespace Tnb.ProductionMgr
|
||||
private static Timer? Floor4DMC2CPKtimer;
|
||||
// 四楼包材自动到二楼包材库
|
||||
private static Timer? PackOutstockServicetimer;
|
||||
// 检查到电梯任务异常断开后处理
|
||||
private Thread? ElevatorTaskExceptionHandleThread;
|
||||
// 二楼空托盘自动补充到线边
|
||||
private static Timer? F2KTPsupplementtimer;
|
||||
// 原材料仓内转移
|
||||
private static Timer? YCLInternalTransfertimer;
|
||||
|
||||
// 原材料仓内转移
|
||||
// 电梯
|
||||
private static Timer? elevatorTimer;
|
||||
// 生成AGV到电梯的任务
|
||||
private static Timer? agvelevatorTimer;
|
||||
|
||||
public SemaphoreSlim s_taskCheckGet = new(1);
|
||||
public SemaphoreSlim s_taskScan = new(1);
|
||||
@@ -116,6 +118,10 @@ namespace Tnb.ProductionMgr
|
||||
public SemaphoreSlim s_taskFloor4DMC2CPKService = new(1);
|
||||
public SemaphoreSlim s_taskF2KTPsupplement = new(1);
|
||||
public SemaphoreSlim s_taskYCLInternalTransfer = new(1);
|
||||
/// <summary>
|
||||
/// AGV到电梯任务
|
||||
/// </summary>
|
||||
public SemaphoreSlim s_agvElevatortaskDic = new(1);
|
||||
|
||||
|
||||
private StackExRedisHelper _redisData;
|
||||
@@ -139,6 +145,8 @@ namespace Tnb.ProductionMgr
|
||||
private ISqlSugarClient db_Floor4DMC2CPK;
|
||||
private ISqlSugarClient db_F2KTPsupplement;
|
||||
private ISqlSugarClient db_YCLInternalTransfer;
|
||||
private ISqlSugarClient db_agvElevatorTaskExceptionHandles;
|
||||
|
||||
|
||||
|
||||
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
|
||||
@@ -196,6 +204,7 @@ namespace Tnb.ProductionMgr
|
||||
db_Floor4DMC2CPK = repository.CopyNew();
|
||||
db_F2KTPsupplement = repository.CopyNew();
|
||||
db_YCLInternalTransfer = repository.CopyNew();
|
||||
db_agvElevatorTaskExceptionHandles = repository.CopyNew();
|
||||
|
||||
List<string> elevatorAreas = repository.CopyNew().Queryable<WmsElevatorH>().Select(r => r.area_code).Distinct().ToList();
|
||||
foreach (var s_elevatorArea in elevatorAreas)
|
||||
@@ -317,69 +326,69 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
#region 弃用
|
||||
|
||||
|
||||
//获取redis数据
|
||||
private async void GetRedisData(object? state)
|
||||
{
|
||||
var _redisReadConfigs = _repository.AsQueryable().Where(p => p.enabled == 1).ToList();
|
||||
foreach (var config in _redisReadConfigs)
|
||||
{
|
||||
try
|
||||
{
|
||||
var json = await _redisData.GetHash(config.dev_name!, config.tag_name!);
|
||||
if (json == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(json);
|
||||
if (config.data_type == (int)DataType.INT)
|
||||
{
|
||||
if (config.check_type == (int)CheckType.相等)
|
||||
{
|
||||
if (res.Value<int>("Value") == int.Parse(config.data!))
|
||||
{
|
||||
InstockInput instockInput = new()
|
||||
{
|
||||
equip_code = res["DevName"]!.ToString(),
|
||||
label_code = res["TagName"]!.ToString()
|
||||
};
|
||||
TriggerEvent((EventType)config.event_type, instockInput);
|
||||
}
|
||||
}
|
||||
else if (config.check_type == (int)CheckType.包含)
|
||||
{
|
||||
int[] ints = Array.ConvertAll(config.data!.Replace("[", "").Replace("]", "").Split(",", StringSplitOptions.RemoveEmptyEntries), int.Parse);
|
||||
if (ints.Contains(res.Value<int>("Value")))
|
||||
{
|
||||
InstockInput instockInput = new()
|
||||
{
|
||||
equip_code = res["DevName"]!.ToString(),
|
||||
label_code = res["TagName"]!.ToString()
|
||||
};
|
||||
TriggerEvent((EventType)config.event_type, instockInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (config.data_type == (int)DataType.BOOL)
|
||||
{
|
||||
if (config.check_type == (int)CheckType.相等)
|
||||
{
|
||||
if (res.Value<bool>("Value") == bool.Parse(config.data!))
|
||||
{
|
||||
InstockInput instockInput = new()
|
||||
{
|
||||
equip_code = res["DevName"]!.ToString(),
|
||||
label_code = res["TagName"]!.ToString()
|
||||
};
|
||||
TriggerEvent((EventType)config.event_type, instockInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
////获取redis数据
|
||||
//private async void GetRedisData(object? state)
|
||||
//{
|
||||
// var _redisReadConfigs = _repository.AsQueryable().Where(p => p.enabled == 1).ToList();
|
||||
// foreach (var config in _redisReadConfigs)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var json = await _redisData.GetHash(config.dev_name!, config.tag_name!);
|
||||
// if (json == null)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// JObject? res = JsonConvert.DeserializeObject<JObject>(json);
|
||||
// if (config.data_type == (int)DataType.INT)
|
||||
// {
|
||||
// if (config.check_type == (int)CheckType.相等)
|
||||
// {
|
||||
// if (res.Value<int>("Value") == int.Parse(config.data!))
|
||||
// {
|
||||
// InstockInput instockInput = new()
|
||||
// {
|
||||
// equip_code = res["DevName"]!.ToString(),
|
||||
// label_code = res["TagName"]!.ToString()
|
||||
// };
|
||||
// TriggerEvent((EventType)config.event_type, instockInput);
|
||||
// }
|
||||
// }
|
||||
// else if (config.check_type == (int)CheckType.包含)
|
||||
// {
|
||||
// int[] ints = Array.ConvertAll(config.data!.Replace("[", "").Replace("]", "").Split(",", StringSplitOptions.RemoveEmptyEntries), int.Parse);
|
||||
// if (ints.Contains(res.Value<int>("Value")))
|
||||
// {
|
||||
// InstockInput instockInput = new()
|
||||
// {
|
||||
// equip_code = res["DevName"]!.ToString(),
|
||||
// label_code = res["TagName"]!.ToString()
|
||||
// };
|
||||
// TriggerEvent((EventType)config.event_type, instockInput);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else if (config.data_type == (int)DataType.BOOL)
|
||||
// {
|
||||
// if (config.check_type == (int)CheckType.相等)
|
||||
// {
|
||||
// if (res.Value<bool>("Value") == bool.Parse(config.data!))
|
||||
// {
|
||||
// InstockInput instockInput = new()
|
||||
// {
|
||||
// equip_code = res["DevName"]!.ToString(),
|
||||
// label_code = res["TagName"]!.ToString()
|
||||
// };
|
||||
// TriggerEvent((EventType)config.event_type, instockInput);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
private void TriggerEvent(EventType eventType, InstockInput instockInput)
|
||||
{
|
||||
switch (eventType)
|
||||
@@ -1922,7 +1931,10 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成电梯任务
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
async void ElevatorTaskExceptionHandle(object args)
|
||||
{
|
||||
Task[] taskActions = new Task[_wareHouseService.s_elevatortaskDic.Count];
|
||||
@@ -1967,14 +1979,6 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
var e = await _wareHouseService.FindElevatorFromPars(q);
|
||||
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】执行电梯任务时 根据任务单号获取电梯结果 {JsonConvert.SerializeObject(e)}");
|
||||
|
||||
// 存在叉车已放货完成电梯任务还没生成的情况,这种情况等待完成
|
||||
WmsElevatorH wmsElevator = await db_ElevatorTaskExceptionHandle.Queryable<WmsElevatorH>().Where(r => r.elevator_id == e.device_id).FirstAsync();
|
||||
if (wmsElevator.carry_count != elevatorTasks.Count)
|
||||
{
|
||||
throw new Exception($"电梯{e.elevator_code}内放货托盘为{wmsElevator.carry_count}托,已生成的电梯任务为{elevatorTasks.Count},需要等待电梯任务生成");
|
||||
}
|
||||
|
||||
|
||||
// 三、四号梯发货带两托货
|
||||
string[] doubleCarryRunElevators =
|
||||
{
|
||||
@@ -1982,6 +1986,13 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
};
|
||||
if (doubleCarryRunElevators.Contains(e.elevator_code) && wmsDistaskHs[0].end_floor == 1)
|
||||
{
|
||||
// 存在叉车已放货完成电梯任务还没生成的情况,这种情况等待完成
|
||||
WmsElevatorH wmsElevator = await db_ElevatorTaskExceptionHandle.Queryable<WmsElevatorH>().Where(r => r.elevator_id == e.device_id).FirstAsync();
|
||||
if (wmsElevator.carry_count != elevatorTasks.Count)
|
||||
{
|
||||
throw new Exception($"电梯{e.elevator_code}内放货托盘为{wmsElevator.carry_count}托,已生成的电梯任务为{elevatorTasks.Count},需要等待电梯任务生成");
|
||||
}
|
||||
|
||||
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】判断为三四号梯任务");
|
||||
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】现在{e.elevator_code}有{group.Count()}托货");
|
||||
// 电梯内放置两托货呼叫电梯下
|
||||
@@ -2065,6 +2076,201 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
Task.WaitAll(taskActions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 电梯第三次改动 生成Agv到电梯任务
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
async void AgvelevatorTimerTaskExceptionHandle(object args)
|
||||
{
|
||||
if (s_agvElevatortaskDic.CurrentCount == 0)
|
||||
return;
|
||||
await s_agvElevatortaskDic.WaitAsync();
|
||||
|
||||
try
|
||||
{
|
||||
// 获取暂存区需要生成任务的库位
|
||||
List<BasLocation> agvElevatorStartLocs = await db_agvElevatorTaskExceptionHandles.Queryable<BasLocation>()
|
||||
.Where(r => r.region_id == WmsWareHouseConst.REGION_CPOutstockCache_ID && r.is_use == "1" && r.is_lock == 0).ToListAsync();
|
||||
|
||||
if (agvElevatorStartLocs.Count > 0)
|
||||
{
|
||||
LoggerAgvElevatorTask.Information($"【AgvelevatorTimerTaskExceptionHandle】检查到需要下发到一楼任务的暂存区库位{agvElevatorStartLocs.Count}条 {string.Join(',', agvElevatorStartLocs.Select(x => x.location_code))}");
|
||||
|
||||
List<IGrouping<string, BasLocation>> elevatorTaskGroup = agvElevatorStartLocs.GroupBy(r => r.region_id).ToList();
|
||||
foreach (IGrouping<string, BasLocation> group in elevatorTaskGroup)
|
||||
{
|
||||
// 选一楼出货库位
|
||||
List<BasLocation> outLocations = await db_agvElevatorTaskExceptionHandles.Queryable<BasLocation>()
|
||||
.Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0")
|
||||
.OrderBy("task_nums, location_code").ToListAsync();
|
||||
|
||||
if (outLocations.Count == 0)
|
||||
{
|
||||
LoggerAgvElevatorTask.LogWarning($"一楼没有可用的出货库位");
|
||||
continue;
|
||||
}
|
||||
BasLocation outLocation = outLocations.FirstOrDefault();
|
||||
WmsPointH outPoint = await db_agvElevatorTaskExceptionHandles.Queryable<WmsPointH>().FirstAsync(it => it.location_id == outLocation.id);
|
||||
|
||||
List<BasLocation> locs = group.ToList();
|
||||
LoggerAgvElevatorTask.LogWarning($"即将下发{locs.Count}条任务");
|
||||
for (int i = 0; i < locs.Count; i++)
|
||||
{
|
||||
// 交替选择缓存区库位
|
||||
var YCLInnerTransfer = await db_agvElevatorTaskExceptionHandles.Queryable<BasFactoryConfig>().Where(p => p.key == "floor3CurOutCacheLocation").FirstAsync();
|
||||
|
||||
if (YCLInnerTransfer.value == null || (YCLInnerTransfer.value != "3楼发货左" && YCLInnerTransfer.value != "3楼发货右"))
|
||||
{
|
||||
throw new AppFriendlyException($"工厂配置->三楼出库暂存区当前出库分区 项配置错误!需要配置值为【3楼发货左】或【3楼发货右】", 500);
|
||||
}
|
||||
|
||||
BasLocation startloc = null;
|
||||
if (group.Key == WmsWareHouseConst.REGION_CPOutstockCache_ID)
|
||||
{
|
||||
List<BasLocation> locations = await db_agvElevatorTaskExceptionHandles.Queryable<BasLocation>()
|
||||
.InnerJoin<WmsElevatorcacheArea>((a, b) => a.id == b.location_id)
|
||||
.Where((a, b) => b.name == YCLInnerTransfer.value).OrderBy("a.location_code,a.is_lock,a.is_use,task_nums").ToListAsync();
|
||||
startloc = locations.FirstOrDefault();
|
||||
}
|
||||
List<WmsCarryH> wmsCarryHs = await db_agvElevatorTaskExceptionHandles.Queryable<WmsCarryH>().Where(r => r.location_id == startloc.id).ToListAsync();
|
||||
if (wmsCarryHs.Count > 1)
|
||||
{
|
||||
LoggerAgvElevatorTask.LogWarning($"暂存区库位{startloc.location_code}上存在多个托盘{string.Join(',', wmsCarryHs.Select(x => x.carry_code))}");
|
||||
continue;
|
||||
}
|
||||
if (wmsCarryHs.Count == 1)
|
||||
{
|
||||
LoggerAgvElevatorTask.LogWarning($"暂存区库位{startloc.location_code}上不存在托盘");
|
||||
continue;
|
||||
}
|
||||
WmsCarryH wmsCarryH = wmsCarryHs.FirstOrDefault();
|
||||
|
||||
WmsElevatorH wmsElevatorH = null;
|
||||
// 选电梯
|
||||
if (group.Key == WmsWareHouseConst.REGION_CPOutstockCache_ID)
|
||||
{
|
||||
List<WmsElevatorH> wmsElevatorHs = await db_agvElevatorTaskExceptionHandles.Queryable<WmsElevatorH>().Where(r => r.elevator_group == "2" && r.enabled == 1).ToListAsync();
|
||||
|
||||
foreach (WmsElevatorH _wmsElevatorH in wmsElevatorHs)
|
||||
{
|
||||
// 加上暂存区到电梯的任务数
|
||||
List<WmsPretaskH> wmsPretaskHs = await db_agvElevatorTaskExceptionHandles.Queryable<WmsPretaskH>()
|
||||
.Where(r => r.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID || r.status != WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID && r.startlocation_id == startloc.id).ToListAsync();
|
||||
|
||||
_wmsElevatorH.carry_count += wmsPretaskHs.Count;
|
||||
}
|
||||
|
||||
wmsElevatorH = wmsElevatorHs.OrderBy(r => r.carry_count).FirstOrDefault();
|
||||
}
|
||||
|
||||
string elevatorSno = wmsElevatorH.elevator_code.Replace("Elevator", "");
|
||||
|
||||
List<WmsPointH> wmsPointHs = await db_agvElevatorTaskExceptionHandles.Queryable<WmsPointH>().Where(it => it.status == 1).ToListAsync();
|
||||
List<WmsPointH> points = new List<WmsPointH>();
|
||||
|
||||
// 到电梯
|
||||
WmsPointH cacheOut_point = wmsPointHs.Where(r => r.location_code == startloc.location_code).First().Copy();
|
||||
WmsPointH DT_C_point = wmsPointHs.Where(r => r.point_code == $"DT-C-03-0{elevatorSno}").First().Copy();
|
||||
cacheOut_point.area_code = "FC";
|
||||
DT_C_point.area_code = "FC";
|
||||
|
||||
points.Add(cacheOut_point);
|
||||
points.Add(DT_C_point);
|
||||
// 到一楼
|
||||
points.Add(wmsPointHs.Where(r => r.point_code == $"DT-3-{elevatorSno}").First());
|
||||
points.Add(wmsPointHs.Where(r => r.point_code == $"DT-1-{elevatorSno}").First());
|
||||
points.Add(wmsPointHs.Where(r => r.point_code == $"DT-R-01-0{elevatorSno}").First());
|
||||
points.Add(outPoint);
|
||||
|
||||
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
|
||||
if (points?.Count > 0)
|
||||
{
|
||||
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 = wmsCarryH.biz_type,
|
||||
task_type = WmsWareHouseConst.WMS_PRETASK_TRANSFER_TYPE_ID
|
||||
};
|
||||
preTask.carry_id = wmsCarryH.id;
|
||||
preTask.carry_code = wmsCarryH.carry_code;
|
||||
preTask.area_id = sPoint?.area_id!;
|
||||
preTask.area_code = it.Key;
|
||||
// 载具记录 require_id todo
|
||||
preTask.require_id = wmsCarryH.require_id;
|
||||
preTask.require_code = "";
|
||||
preTask.create_id = _userManager.UserId;
|
||||
preTask.create_time = DateTime.Now;
|
||||
return preTask;
|
||||
}).ToList();
|
||||
bool isOk = await _wareHouseService.GenPreTask(preTasks, null!, db_agvElevatorTaskExceptionHandles);
|
||||
if (isOk)
|
||||
{
|
||||
//查询库位表
|
||||
BasLocation location = await db_agvElevatorTaskExceptionHandles.Queryable<BasLocation>().SingleAsync(it => it.id == startloc.id);
|
||||
{
|
||||
//载具加锁,增加库位信息
|
||||
_ = await db_agvElevatorTaskExceptionHandles.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH
|
||||
{
|
||||
carry_status = ((int)EnumCarryStatus.占用).ToString(),
|
||||
is_lock = 1,
|
||||
location_id = startloc.id,
|
||||
location_code = location.location_code
|
||||
}).Where(it => it.id == wmsCarryH.id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await db_agvElevatorTaskExceptionHandles.Updateable<BasFactoryConfig>().SetColumns(r => r.value == (YCLInnerTransfer.value == "3楼发货左" ? "3楼发货右" : "3楼发货左"))
|
||||
.Where(r => r.key == "floor3CurOutCacheLocation").ExecuteCommandAsync();
|
||||
|
||||
//所有库位加锁
|
||||
string?[] ids = new[] { startloc.id, preTasks[0].endlocation_id, outLocation.id };
|
||||
_ = await db_agvElevatorTaskExceptionHandles.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_lock = 1 }).Where(it => ids.Contains(it.id)).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("预任务生成失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ObjectDisposedException ex)
|
||||
{
|
||||
LoggerAgvElevatorTask.LogWarning($"【AgvelevatorTimerTaskExceptionHandle】 数据库连接异常:{ex.Message}");
|
||||
LoggerAgvElevatorTask.LogWarning($"【AgvelevatorTimerTaskExceptionHandle】 数据库连接异常:{ex.StackTrace}");
|
||||
if (ex.Source == "Npgsql")
|
||||
db_agvElevatorTaskExceptionHandles = _repository.AsSugarClient().CopyNew();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("【AgvelevatorTimerTaskExceptionHandle】" + ex.Message);
|
||||
LoggerAgvElevatorTask.LogError($"【AgvelevatorTimerTaskExceptionHandle】 {ex.Message}");
|
||||
LoggerAgvElevatorTask.LogError($"【AgvelevatorTimerTaskExceptionHandle】 {ex.StackTrace}");
|
||||
// 数据库连接断开时会报错
|
||||
try { await db_agvElevatorTaskExceptionHandles.Ado.RollbackTranAsync(); } catch { };
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_agvElevatortaskDic.Release();
|
||||
}
|
||||
}
|
||||
|
||||
#region 内存测试
|
||||
|
||||
@@ -2695,6 +2901,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
YCLInternalTransfertimer = new Timer(YCLInternalTransfer, null, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(185));
|
||||
|
||||
elevatorTimer = new Timer(ElevatorTaskExceptionHandle, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(20));
|
||||
//agvelevatorTimer = new Timer(AgvelevatorTimerTaskExceptionHandle, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(20));
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -2724,10 +2932,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
Floor4DMJ2MJXtimer?.Dispose();
|
||||
Floor4MJX2MJCtimer?.Dispose();
|
||||
Floor4DMC2CPKtimer?.Dispose();
|
||||
ElevatorTaskExceptionHandleThread.Abort();
|
||||
F2KTPsupplementtimer?.Dispose();
|
||||
YCLInternalTransfertimer?.Dispose();
|
||||
elevatorTimer?.Dispose();
|
||||
agvelevatorTimer?.Dispose();
|
||||
|
||||
}
|
||||
|
||||
#region 日志
|
||||
@@ -2775,6 +2984,39 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
}
|
||||
}
|
||||
|
||||
protected string _LoggerAgvElevatorTaskFileName = "";
|
||||
protected ILogger _LoggerAgvElevatorTask;
|
||||
protected ILogger LoggerAgvElevatorTask
|
||||
{
|
||||
get
|
||||
{
|
||||
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/custom{DateTime.Now:yyyyMMdd}AgvElevatorTask.log";
|
||||
if (_LoggerAgvElevatorTaskFileName != newFileName)
|
||||
{
|
||||
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>
|
||||
{
|
||||
|
||||
//cfgOpts.DateFormat = "yyyy-MM-dd HH:mm:ss.fff";
|
||||
cfgOpts.MessageFormat = (logMsg) =>
|
||||
{
|
||||
var logLevel = s_logLevelMap[logMsg.LogLevel];
|
||||
var sb = new StringBuilder();
|
||||
_ = sb.Append($"[{logLevel}] ");
|
||||
_ = sb.Append($"{logMsg.LogName} ");
|
||||
_ = sb.Append($"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} ");
|
||||
_ = sb.Append($"#{logMsg.EventId.Id} ");
|
||||
_ = sb.Append(logMsg.Message + " ");
|
||||
_ = sb.Append(logMsg.Exception?.ToString());
|
||||
return sb.ToString();
|
||||
};
|
||||
|
||||
}));
|
||||
_LoggerAgvElevatorTask = loggerFactory.CreateLogger(this.GetType());
|
||||
_LoggerAgvElevatorTaskFileName = newFileName;
|
||||
}
|
||||
return _LoggerAgvElevatorTask;
|
||||
}
|
||||
}
|
||||
|
||||
protected string _LoggerSSXFileName = "";
|
||||
protected ILogger _LoggerSSX;
|
||||
|
||||
@@ -542,6 +542,19 @@
|
||||
/// 一楼外协三工位库位
|
||||
/// </summary>
|
||||
public const string Floor1WXSGWOutstockStation3 = "35704230368021";
|
||||
|
||||
/// <summary>
|
||||
/// 原材料出库到月台库位
|
||||
/// </summary>
|
||||
public const string Floor1OutstockStation1 = "30773146852471";
|
||||
/// <summary>
|
||||
/// 原材料出库到月台库位
|
||||
/// </summary>
|
||||
public const string Floor1OutstockStation2 = "30773146852472";
|
||||
/// <summary>
|
||||
/// 原材料出库到月台库位
|
||||
/// </summary>
|
||||
public const string Floor1OutstockStation3 = "30773146852473";
|
||||
/// <summary>
|
||||
/// 分拣任务生成Encode
|
||||
/// </summary>
|
||||
|
||||
@@ -149,4 +149,14 @@ public partial class WmsCarryH : BaseEntity<string>
|
||||
/// 转库单ID
|
||||
/// </summary>
|
||||
public string? material_tranfer_billid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 业务类型(电梯)
|
||||
/// </summary>
|
||||
public string? biz_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 需求单据(电梯)
|
||||
/// </summary>
|
||||
public string? require_id { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Entity;
|
||||
|
||||
/// <summary>
|
||||
/// 电梯缓存分区配置表
|
||||
/// </summary>
|
||||
[SugarTable("wms_elevatorcache_area")]
|
||||
public partial class WmsElevatorcacheArea : BaseEntity<string>
|
||||
{
|
||||
public WmsElevatorcacheArea()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 区域
|
||||
/// </summary>
|
||||
public string? name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库位id
|
||||
/// </summary>
|
||||
public string? location_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库位编码
|
||||
/// </summary>
|
||||
public string? location_code { get; set; }
|
||||
|
||||
}
|
||||
@@ -39,6 +39,11 @@ public partial class WmsOutsourceOrderD : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位id
|
||||
/// </summary>
|
||||
public string? unit_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 委外数量
|
||||
/// </summary>
|
||||
|
||||
@@ -115,5 +115,13 @@ public partial class WmsTempCode : BaseEntity<string>
|
||||
/// 需求单据类型
|
||||
/// </summary>
|
||||
public string? required_type { get; set; }
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string? material_name { get; set; }
|
||||
/// <summary>
|
||||
/// 供应商
|
||||
/// </summary>
|
||||
public string? supplier_name { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Tnb.WarehouseMgr.Interfaces
|
||||
SemaphoreSlim s_taskExecuteSemaphore_F2ZCCOutstock { get; }
|
||||
|
||||
SemaphoreSlim _s_GenTaskExecute { get; }
|
||||
|
||||
//电梯任务
|
||||
Dictionary<string, SemaphoreSlim> s_elevatortaskDic
|
||||
{
|
||||
get;
|
||||
@@ -44,13 +44,12 @@ namespace Tnb.WarehouseMgr.Interfaces
|
||||
get;
|
||||
}
|
||||
/// <summary>
|
||||
/// WCS请求
|
||||
/// 电梯任务WCS请求
|
||||
/// </summary>
|
||||
public Dictionary<string, SemaphoreSlim> s_elevatortaskWCSRequestDic
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取锁
|
||||
/// </summary>
|
||||
|
||||
@@ -107,6 +107,8 @@ namespace Tnb.WarehouseMgr
|
||||
public static Dictionary<string, SemaphoreSlim> _s_elevatortaskWCSRequestDic = new();
|
||||
public static List<ISqlSugarClient> _db_ElevatorTaskExceptionHandles = new();
|
||||
|
||||
|
||||
|
||||
public static SemaphoreSlim s_GenTaskExecute = new(1);
|
||||
protected IEventPublisher? EventPublisher { set; get; }
|
||||
|
||||
|
||||
@@ -415,10 +415,12 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
|
||||
// 如果还未判定几托下,判断是否放了两托货
|
||||
elevatorTasks = _db.Queryable<WmsDistaskH>()
|
||||
.Where(r => r.startlocation_code == $"DT-3-{sno}" && r.endlocation_code == $"DT-1-{sno}" && r.act_start_date == null && r.act_end_date == null
|
||||
&& r.status != WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID && r.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).ToList();
|
||||
if (elevatorTasks.Count >= 2)
|
||||
// elevatorTasks = _db.Queryable<WmsDistaskH>()
|
||||
//.Where(r => r.startlocation_code == $"DT-3-{sno}" && r.endlocation_code == $"DT-1-{sno}" && r.act_start_date == null && r.act_end_date == null
|
||||
//&& r.status != WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID && r.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).ToList();
|
||||
|
||||
// 电梯第三次改动
|
||||
if (elevator.carry_count >= 2)
|
||||
{
|
||||
Logger.LogInformation($"电梯内{devName}已有两托货!");
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, $"电梯内{devName}已有两托货!");
|
||||
@@ -946,7 +948,8 @@ namespace Tnb.WarehouseMgr
|
||||
await _db.Updateable<WmsElevatorH>().SetColumns(r => new WmsElevatorH
|
||||
{
|
||||
is_use = (int)EnumElevatorUseStatus.空闲,
|
||||
use_tasks = ""
|
||||
use_tasks = "",
|
||||
carry_count = 0
|
||||
})
|
||||
.Where(it => it.elevator_id == wmsElevatorH.elevator_id).ExecuteCommandAsync();
|
||||
|
||||
|
||||
@@ -338,8 +338,6 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
await db.Ado.BeginTranAsync();
|
||||
|
||||
if (details.Count > 0)
|
||||
{
|
||||
// 判断是否为重复传输的采购订单
|
||||
WmsPurchaseOrderH wmsPurchaseOrderRep = await db.Queryable<WmsPurchaseOrderH>().Where(r => r.erp_pk == input.erp_pk).FirstAsync();
|
||||
if (wmsPurchaseOrderRep != null)
|
||||
@@ -358,6 +356,27 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
|
||||
// 判断是否为重复传输的采购退料订单
|
||||
WmsPurchaseReturnH wmsPurchaseReturnRep = await db.Queryable<WmsPurchaseReturnH>().Where(r => r.erp_pk == input.erp_pk).FirstAsync();
|
||||
if (wmsPurchaseReturnRep != null)
|
||||
{
|
||||
// 判断采购退货是否已经下发
|
||||
List<WmsPurchaseReturnD> wmsPurchaseReturnDReps = await db.Queryable<WmsPurchaseReturnD>().Where(r => r.bill_id == wmsPurchaseReturnRep.id).ToListAsync();
|
||||
if (wmsPurchaseReturnDReps.Where(r => r.actual_qty > 0).Count() > 0)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【PurchaseOrderInput】wms采购退货单{wmsPurchaseReturnRep.bill_code}已下发,不能退回!");
|
||||
throw new AppFriendlyException($@"wms采购退货单{wmsPurchaseReturnRep.bill_code}已下发,不能退回!", 500);
|
||||
}
|
||||
else // 删除数据重新插入
|
||||
{
|
||||
await db.Deleteable<WmsPurchaseReturnH>().Where(r => r.id == wmsPurchaseReturnRep.id).ExecuteCommandAsync();
|
||||
await db.Deleteable<WmsPurchaseReturnD>().Where(r => r.bill_id == wmsPurchaseReturnRep.id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
if (details.Count > 0)
|
||||
{
|
||||
|
||||
WmsPurchaseOrderH wmsPurchaseOrderH = new WmsPurchaseOrderH();
|
||||
string Code = await _billRuleService.GetBillNumber("Purchase");
|
||||
|
||||
@@ -389,7 +408,7 @@ namespace Tnb.WarehouseMgr
|
||||
wmsPurchaseOrderD.matcode = detail.material_code;
|
||||
wmsPurchaseOrderD.unit = detail.unit_code;
|
||||
|
||||
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)
|
||||
{
|
||||
wmsPurchaseOrderD.unit_id = erpExtendField.Id;
|
||||
@@ -428,23 +447,6 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
if (details_return.Count > 0)
|
||||
{
|
||||
// 判断是否为重复传输的采购退料订单
|
||||
WmsPurchaseReturnH wmsPurchaseReturnRep = await db.Queryable<WmsPurchaseReturnH>().Where(r => r.erp_pk == input.erp_pk).FirstAsync();
|
||||
if (wmsPurchaseReturnRep != null)
|
||||
{
|
||||
// 判断采购退货是否已经下发
|
||||
List<WmsPurchaseReturnD> wmsPurchaseReturnDReps = await db.Queryable<WmsPurchaseReturnD>().Where(r => r.bill_id == wmsPurchaseReturnRep.id).ToListAsync();
|
||||
if (wmsPurchaseReturnDReps.Where(r => r.actual_qty > 0).Count() > 0)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【PurchaseOrderInput】wms采购退货单{wmsPurchaseReturnRep.bill_code}已下发,不能退回!");
|
||||
throw new AppFriendlyException($@"wms采购退货单{wmsPurchaseReturnRep.bill_code}已下发,不能退回!", 500);
|
||||
}
|
||||
else // 删除数据重新插入
|
||||
{
|
||||
await db.Deleteable<WmsPurchaseReturnH>().Where(r => r.id == wmsPurchaseReturnRep.id).ExecuteCommandAsync();
|
||||
await db.Deleteable<WmsPurchaseReturnD>().Where(r => r.bill_id == wmsPurchaseReturnRep.id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
WmsPurchaseReturnH wmsPurchaseReturnH = new WmsPurchaseReturnH();
|
||||
string Code = await _billRuleService.GetBillNumber("WmsPurchaseReturn");
|
||||
@@ -478,7 +480,7 @@ namespace Tnb.WarehouseMgr
|
||||
wmsPurchaseReturnD.unit = detail.unit_code;
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
wmsPurchaseReturnD.unit = erpExtendField.EnCode;
|
||||
@@ -569,7 +571,7 @@ namespace Tnb.WarehouseMgr
|
||||
await db.Ado.BeginTranAsync();
|
||||
|
||||
// 判断是否为重复传输
|
||||
WmsOutsourceOrderH wmsOutsourceOrderHRep = await db.Queryable<WmsOutsourceOrderH>().Where(r => r.erp_pk == input.erp_pk).FirstAsync();
|
||||
WmsOutsourceOrderH wmsOutsourceOrderHRep = await db.Queryable<WmsOutsourceOrderH>().Where(r => r.erp_bill_code == input.outsource_order).FirstAsync();
|
||||
if (wmsOutsourceOrderHRep != null)
|
||||
{
|
||||
// 判断是否已经下发
|
||||
@@ -620,6 +622,7 @@ namespace Tnb.WarehouseMgr
|
||||
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();
|
||||
if (erpExtendField != null)
|
||||
{
|
||||
wmsOutsourceOrderD.unit_id = erpExtendField.Id;
|
||||
wmsOutsourceOrderD.unit = erpExtendField.EnCode;
|
||||
}
|
||||
else
|
||||
@@ -776,7 +779,7 @@ namespace Tnb.WarehouseMgr
|
||||
await db.Ado.BeginTranAsync();
|
||||
|
||||
// 判断是否重复传输
|
||||
WmsMaterialTransfer wmsMaterialTransferRep = await db.Queryable<WmsMaterialTransfer>().Where(r => r.erp_pk == input.erp_pk).FirstAsync();
|
||||
WmsMaterialTransfer wmsMaterialTransferRep = await db.Queryable<WmsMaterialTransfer>().Where(r => r.erp_bill_code == input.bill_code).FirstAsync();
|
||||
if (wmsMaterialTransferRep != null)
|
||||
{
|
||||
// 判断单据是否已经下发
|
||||
@@ -1142,13 +1145,8 @@ namespace Tnb.WarehouseMgr
|
||||
// throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500);
|
||||
//}
|
||||
await db.Ado.BeginTranAsync();
|
||||
string Code = "";
|
||||
switch (warehouse_instock.id)
|
||||
{
|
||||
case WmsWareHouseConst.WAREHOUSE_YCL_ID:
|
||||
{
|
||||
// 判断是否重复传输
|
||||
WmsRawmatTransferinstockH wmsRawmatTransferinstockHRep = await db.Queryable<WmsRawmatTransferinstockH>().Where(r => r.erp_pk == input.erp_pk).FirstAsync();
|
||||
WmsRawmatTransferinstockH wmsRawmatTransferinstockHRep = await db.Queryable<WmsRawmatTransferinstockH>().Where(r => r.erp_bill_code == input.transfer_order).FirstAsync();
|
||||
if (wmsRawmatTransferinstockHRep != null)
|
||||
{
|
||||
// 判断单据是否已经下发
|
||||
@@ -1165,7 +1163,48 @@ namespace Tnb.WarehouseMgr
|
||||
await db.Deleteable<WmsRawmatTransferinstockD>().Where(r => r.bill_id == wmsRawmatTransferinstockHRep.id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
// 判断是否重复传输
|
||||
WmsTransferInstockH wmsTransferInstockHRep = await db.Queryable<WmsTransferInstockH>().Where(r => r.erp_bill_code == input.transfer_order).FirstAsync();
|
||||
if (wmsTransferInstockHRep != null)
|
||||
{
|
||||
// 判断单据是否已经下发
|
||||
List<WmsTransferInstockD> _wmsTransferInstockDs = await db.Queryable<WmsTransferInstockD>().Where(r => r.bill_id == wmsTransferInstockHRep.id).ToListAsync();
|
||||
bool isxf = _wmsTransferInstockDs.Where(r => r.xf_qty > 0).Any();
|
||||
if (isxf)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【TransferOutstock】wms已下发使用调拨出库单{input.transfer_order}!");
|
||||
throw new AppFriendlyException($@"wms已下发使用调拨出库单{input.transfer_order}!", 500);
|
||||
}
|
||||
else // 删除数据重新插入
|
||||
{
|
||||
await db.Deleteable<WmsTransferInstockH>().Where(r => r.id == wmsTransferInstockHRep.id).ExecuteCommandAsync();
|
||||
await db.Deleteable<WmsTransferInstockD>().Where(r => r.bill_id == wmsTransferInstockHRep.id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
// 判断是否重复传输
|
||||
WmsPackInstockH wmsPackInstockHRep = await db.Queryable<WmsPackInstockH>().Where(r => r.erp_bill_code == input.transfer_order).FirstAsync();
|
||||
if (wmsPackInstockHRep != null)
|
||||
{
|
||||
// 判断单据是否已经下发
|
||||
List<WmsPackInstockD> _wmsPackInstocDs = await db.Queryable<WmsPackInstockD>().Where(r => r.bill_id == wmsPackInstockHRep.id).ToListAsync();
|
||||
bool isxf = _wmsPackInstocDs.Where(r => r.xf_qty > 0).Any();
|
||||
if (isxf)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【TransferOutstock】wms已下发使用调拨出库单{input.transfer_order}!");
|
||||
throw new AppFriendlyException($@"wms已下发使用调拨出库单{input.transfer_order}!", 500);
|
||||
}
|
||||
else // 删除数据重新插入
|
||||
{
|
||||
await db.Deleteable<WmsPackInstockH>().Where(r => r.id == wmsPackInstockHRep.id).ExecuteCommandAsync();
|
||||
await db.Deleteable<WmsPackInstockD>().Where(r => r.bill_id == wmsPackInstockHRep.id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
string Code = "";
|
||||
switch (warehouse_instock.id)
|
||||
{
|
||||
case WmsWareHouseConst.WAREHOUSE_YCL_ID:
|
||||
{
|
||||
WmsRawmatTransferinstockH wmsRawmatTransferinstockH = new WmsRawmatTransferinstockH();
|
||||
Code = await _billRuleService.GetBillNumber("WmsRawMatTransferInstock");
|
||||
|
||||
@@ -1239,25 +1278,6 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
case WmsWareHouseConst.WAREHOUSE_CP_ID:
|
||||
{
|
||||
// 判断是否重复传输
|
||||
WmsTransferInstockH wmsTransferInstockHRep = await db.Queryable<WmsTransferInstockH>().Where(r => r.erp_pk == input.erp_pk).FirstAsync();
|
||||
if (wmsTransferInstockHRep != null)
|
||||
{
|
||||
// 判断单据是否已经下发
|
||||
List<WmsTransferInstockD> _wmsTransferInstockDs = await db.Queryable<WmsTransferInstockD>().Where(r => r.bill_id == wmsTransferInstockHRep.id).ToListAsync();
|
||||
bool isxf = _wmsTransferInstockDs.Where(r => r.xf_qty > 0).Any();
|
||||
if (isxf)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【TransferOutstock】wms已下发使用调拨出库单{input.transfer_order}!");
|
||||
throw new AppFriendlyException($@"wms已下发使用调拨出库单{input.transfer_order}!", 500);
|
||||
}
|
||||
else // 删除数据重新插入
|
||||
{
|
||||
await db.Deleteable<WmsTransferInstockH>().Where(r => r.id == wmsTransferInstockHRep.id).ExecuteCommandAsync();
|
||||
await db.Deleteable<WmsTransferInstockD>().Where(r => r.bill_id == wmsTransferInstockHRep.id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
WmsTransferInstockH wmsTransferInstockH = new WmsTransferInstockH();
|
||||
Code = await _billRuleService.GetBillNumber("transferInstock");
|
||||
|
||||
@@ -1329,94 +1349,143 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
case WmsWareHouseConst.WAREHOUSE_JXK_ID:
|
||||
{
|
||||
// 判断是否重复传输
|
||||
WmsPackInstockH wmsPackInstockHRep = await db.Queryable<WmsPackInstockH>().Where(r => r.erp_pk == input.erp_pk).FirstAsync();
|
||||
if (wmsPackInstockHRep != null)
|
||||
{
|
||||
// 判断单据是否已经下发
|
||||
List<WmsPackInstockD> _wmsPackInstocDs = await db.Queryable<WmsPackInstockD>().Where(r => r.bill_id == wmsPackInstockHRep.id).ToListAsync();
|
||||
bool isxf = _wmsPackInstocDs.Where(r => r.xf_qty > 0).Any();
|
||||
if (isxf)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【TransferOutstock】wms已下发使用调拨出库单{input.transfer_order}!");
|
||||
throw new AppFriendlyException($@"wms已下发使用调拨出库单{input.transfer_order}!", 500);
|
||||
}
|
||||
else // 删除数据重新插入
|
||||
{
|
||||
await db.Deleteable<WmsPackInstockH>().Where(r => r.id == wmsPackInstockHRep.id).ExecuteCommandAsync();
|
||||
await db.Deleteable<WmsPackInstockD>().Where(r => r.bill_id == wmsPackInstockHRep.id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
WmsTransferInstockH wmsTransferInstockH = new WmsTransferInstockH();
|
||||
Code = await _billRuleService.GetBillNumber("transferInstock");
|
||||
|
||||
WmsPackInstockH wmsPackInstockH = new WmsPackInstockH();
|
||||
Code = await _billRuleService.GetBillNumber("WMSPACKINSTOCK");
|
||||
|
||||
wmsPackInstockH.bill_code = Code;
|
||||
wmsPackInstockH.erp_bill_code = input.transfer_order;
|
||||
wmsTransferInstockH.bill_code = Code;
|
||||
wmsTransferInstockH.erp_bill_code = input.transfer_order;
|
||||
var org_erpExtendField = await db.Queryable<ErpExtendField>().Where(a => a.pk_org == input.outstockorg_id).FirstAsync();
|
||||
if (org_erpExtendField != null)
|
||||
{
|
||||
wmsPackInstockH.outstockorg_id = org_erpExtendField.pk_org_v;
|
||||
wmsPackInstockH.outstockorg_code = org_erpExtendField.pk_org;
|
||||
wmsTransferInstockH.outstockorg_id = org_erpExtendField.pk_org_v;
|
||||
wmsTransferInstockH.outstockorg_code = org_erpExtendField.pk_org;
|
||||
}
|
||||
else
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【TransferOutstock】表头明细中组织{input.outstockorg_id}在wms系统中未找到!");
|
||||
throw new AppFriendlyException($@"表头明细中组织{input.outstockorg_id}在wms系统中未找到!", 500);
|
||||
}
|
||||
wmsPackInstockH.incoming_ware = warehouse_instock.id;
|
||||
wmsPackInstockH.org_id = WmsWareHouseConst.AdministratorOrgId;
|
||||
wmsPackInstockH.erp_pk = input.erp_pk;
|
||||
wmsPackInstockH.create_id = WmsWareHouseConst.ErpUserId;
|
||||
wmsPackInstockH.bill_date = DateTime.Now;
|
||||
wmsPackInstockH.create_time = DateTime.Now;
|
||||
wmsPackInstockH.erp_wh_type = input.warehouse_instock;
|
||||
await db.Insertable(wmsPackInstockH).ExecuteCommandAsync();
|
||||
wmsTransferInstockH.incoming_ware = warehouse_instock.id;
|
||||
wmsTransferInstockH.org_id = WmsWareHouseConst.AdministratorOrgId;
|
||||
wmsTransferInstockH.erp_pk = input.erp_pk;
|
||||
wmsTransferInstockH.create_id = WmsWareHouseConst.ErpUserId;
|
||||
wmsTransferInstockH.create_time = DateTime.Now;
|
||||
wmsTransferInstockH.dept_code = input.dept_code;
|
||||
wmsTransferInstockH.biller = input.biller;
|
||||
wmsTransferInstockH.erp_wh_type = input.warehouse_instock;
|
||||
await db.Insertable(wmsTransferInstockH).ExecuteCommandAsync();
|
||||
|
||||
List<WmsPackInstockD> wmsPackInstockDs = new List<WmsPackInstockD>();
|
||||
List<WmsTransferInstockD> wmsTransferInstockDs = new List<WmsTransferInstockD>();
|
||||
foreach (var detail in input.details)
|
||||
{
|
||||
WmsPackInstockD wmsPackInstockD = new WmsPackInstockD();
|
||||
WmsTransferInstockD wmsTransferInstockD = new WmsTransferInstockD();
|
||||
|
||||
wmsPackInstockD.bill_id = wmsPackInstockH.id;
|
||||
wmsPackInstockD.material_code = detail.material_code;
|
||||
wmsTransferInstockD.bill_id = wmsTransferInstockH.id;
|
||||
wmsTransferInstockD.material_code = detail.material_code;
|
||||
|
||||
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();
|
||||
if (erpExtendField != null)
|
||||
{
|
||||
wmsPackInstockD.unit_id = erpExtendField.Id;
|
||||
wmsPackInstockD.unit_code = erpExtendField.EnCode;
|
||||
wmsTransferInstockD.unit_id = erpExtendField.Id;
|
||||
wmsTransferInstockD.unit_code = erpExtendField.EnCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【TransferOutstock】表体明细中单位{detail.unit_code}在wms系统中未找到!");
|
||||
throw new AppFriendlyException($@"表体明细中单位{detail.unit_code}在wms系统中未找到!", 500);
|
||||
}
|
||||
wmsPackInstockD.pr_qty = detail.qty;
|
||||
wmsPackInstockD.pi_code = detail.code_batch;
|
||||
wmsPackInstockD.erp_line_pk = detail.erp_line_pk;
|
||||
wmsPackInstockD.create_id = WmsWareHouseConst.ErpUserId;
|
||||
wmsPackInstockD.create_time = DateTime.Now;
|
||||
wmsPackInstockD.xf_qty = 0;
|
||||
wmsPackInstockD.qty = 0;
|
||||
wmsPackInstockD.lineno = detail.lineno;
|
||||
wmsTransferInstockD.qty = 0;
|
||||
wmsTransferInstockD.stock_location = detail.stock_location;
|
||||
wmsTransferInstockD.pi_code = detail.code_batch;
|
||||
wmsTransferInstockD.erp_line_pk = detail.erp_line_pk;
|
||||
wmsTransferInstockD.create_id = WmsWareHouseConst.ErpUserId;
|
||||
wmsTransferInstockD.create_time = DateTime.Now;
|
||||
wmsTransferInstockD.xf_qty = 0;
|
||||
wmsTransferInstockD.pr_qty = detail.qty;
|
||||
wmsTransferInstockD.lineno = detail.lineno;
|
||||
var material = await db.Queryable<BasMaterial>().Where(p => p.code == detail.material_code).FirstAsync();
|
||||
if (material != null)
|
||||
{
|
||||
wmsPackInstockD.material_id = material.id;
|
||||
wmsPackInstockD.material_code = material.code;
|
||||
wmsPackInstockD.material_desc = material.material_specification;
|
||||
wmsTransferInstockD.material_id = material.id;
|
||||
wmsTransferInstockD.material_code = material.code;
|
||||
wmsTransferInstockD.material_desc = material.material_specification;
|
||||
}
|
||||
|
||||
wmsPackInstockDs.Add(wmsPackInstockD);
|
||||
wmsTransferInstockDs.Add(wmsTransferInstockD);
|
||||
}
|
||||
|
||||
await db.Insertable(wmsPackInstockDs).ExecuteCommandAsync();
|
||||
await db.Insertable(wmsTransferInstockDs).ExecuteCommandAsync();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//WmsPackInstockH wmsPackInstockH = new WmsPackInstockH();
|
||||
//Code = await _billRuleService.GetBillNumber("WMSPACKINSTOCK");
|
||||
|
||||
//wmsPackInstockH.bill_code = Code;
|
||||
//wmsPackInstockH.erp_bill_code = input.transfer_order;
|
||||
//var org_erpExtendField = await db.Queryable<ErpExtendField>().Where(a => a.pk_org == input.outstockorg_id).FirstAsync();
|
||||
//if (org_erpExtendField != null)
|
||||
//{
|
||||
// wmsPackInstockH.outstockorg_id = org_erpExtendField.pk_org_v;
|
||||
// wmsPackInstockH.outstockorg_code = org_erpExtendField.pk_org;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// _LoggerErp2Mes.LogWarning($@"【TransferOutstock】表头明细中组织{input.outstockorg_id}在wms系统中未找到!");
|
||||
// throw new AppFriendlyException($@"表头明细中组织{input.outstockorg_id}在wms系统中未找到!", 500);
|
||||
//}
|
||||
//wmsPackInstockH.incoming_ware = warehouse_instock.id;
|
||||
//wmsPackInstockH.org_id = WmsWareHouseConst.AdministratorOrgId;
|
||||
//wmsPackInstockH.erp_pk = input.erp_pk;
|
||||
//wmsPackInstockH.create_id = WmsWareHouseConst.ErpUserId;
|
||||
//wmsPackInstockH.bill_date = DateTime.Now;
|
||||
//wmsPackInstockH.create_time = DateTime.Now;
|
||||
//wmsPackInstockH.erp_wh_type = input.warehouse_instock;
|
||||
//await db.Insertable(wmsPackInstockH).ExecuteCommandAsync();
|
||||
|
||||
//List<WmsPackInstockD> wmsPackInstockDs = new List<WmsPackInstockD>();
|
||||
//foreach (var detail in input.details)
|
||||
//{
|
||||
// WmsPackInstockD wmsPackInstockD = new WmsPackInstockD();
|
||||
|
||||
// wmsPackInstockD.bill_id = wmsPackInstockH.id;
|
||||
// wmsPackInstockD.material_code = detail.material_code;
|
||||
|
||||
// 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();
|
||||
// if (erpExtendField != null)
|
||||
// {
|
||||
// wmsPackInstockD.unit_id = erpExtendField.Id;
|
||||
// wmsPackInstockD.unit_code = erpExtendField.EnCode;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _LoggerErp2Mes.LogWarning($@"【TransferOutstock】表体明细中单位{detail.unit_code}在wms系统中未找到!");
|
||||
// throw new AppFriendlyException($@"表体明细中单位{detail.unit_code}在wms系统中未找到!", 500);
|
||||
// }
|
||||
// wmsPackInstockD.pr_qty = detail.qty;
|
||||
// wmsPackInstockD.pi_code = detail.code_batch;
|
||||
// wmsPackInstockD.erp_line_pk = detail.erp_line_pk;
|
||||
// wmsPackInstockD.create_id = WmsWareHouseConst.ErpUserId;
|
||||
// wmsPackInstockD.create_time = DateTime.Now;
|
||||
// wmsPackInstockD.xf_qty = 0;
|
||||
// wmsPackInstockD.qty = 0;
|
||||
// wmsPackInstockD.lineno = detail.lineno;
|
||||
// var material = await db.Queryable<BasMaterial>().Where(p => p.code == detail.material_code).FirstAsync();
|
||||
// if (material != null)
|
||||
// {
|
||||
// wmsPackInstockD.material_id = material.id;
|
||||
// wmsPackInstockD.material_code = material.code;
|
||||
// wmsPackInstockD.material_desc = material.material_specification;
|
||||
// }
|
||||
|
||||
// wmsPackInstockDs.Add(wmsPackInstockD);
|
||||
//}
|
||||
|
||||
//await db.Insertable(wmsPackInstockDs).ExecuteCommandAsync();
|
||||
|
||||
//break;
|
||||
}
|
||||
}
|
||||
|
||||
await db.Ado.CommitTranAsync();
|
||||
|
||||
@@ -1473,6 +1542,16 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
|
||||
await db.Ado.BeginTranAsync();
|
||||
|
||||
// 判断是否重复传输
|
||||
WmsTransferOrderH wmsTransferOrderHRep = await db.Queryable<WmsTransferOrderH>().Where(r => r.erp_bill_code == input.transfer_order).FirstAsync();
|
||||
if (wmsTransferOrderHRep != null)
|
||||
{
|
||||
await db.Deleteable<WmsTransferOrderH>().Where(r => r.id == wmsTransferOrderHRep.id).ExecuteCommandAsync();
|
||||
await db.Deleteable<WmsTransferOrderD>().Where(r => r.bill_id == wmsTransferOrderHRep.id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
|
||||
WmsTransferOrderH wmsTransferOrderH = new WmsTransferOrderH();
|
||||
string Code = await _billRuleService.GetBillNumber("WmsTransferOrder");
|
||||
|
||||
@@ -1581,11 +1660,8 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
await db.Insertable(wmsTransferOrderDs).ExecuteCommandAsync();
|
||||
|
||||
|
||||
if (details_WAREHOUSE_YCL_ID.Count > 0)
|
||||
{
|
||||
// 判断是否重复传输
|
||||
WmsRawmatTransferoutstockH wmsRawmatTransferoutstockHRep = await db.Queryable<WmsRawmatTransferoutstockH>().Where(r => r.erp_pk == input.erp_pk).FirstAsync();
|
||||
WmsRawmatTransferoutstockH wmsRawmatTransferoutstockHRep = await db.Queryable<WmsRawmatTransferoutstockH>().Where(r => r.erp_bill_code == input.transfer_order).FirstAsync();
|
||||
if (wmsRawmatTransferoutstockHRep != null)
|
||||
{
|
||||
// 判断单据是否已经下发
|
||||
@@ -1603,6 +1679,29 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 判断是否重复传输
|
||||
WmsTransferOutstockH wmsTransferOutstockHRep = await db.Queryable<WmsTransferOutstockH>().Where(r => r.erp_bill_code == input.transfer_order).FirstAsync();
|
||||
if (wmsTransferOutstockHRep != null)
|
||||
{
|
||||
// 判断单据是否已经下发
|
||||
List<WmsTransferOutstockD> _wmsTransferOutstockDs = await db.Queryable<WmsTransferOutstockD>().Where(r => r.bill_id == wmsTransferOutstockHRep.id).ToListAsync();
|
||||
bool isxf = _wmsTransferOutstockDs.Where(r => r.xf_qty > 0).Any();
|
||||
if (isxf)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【TransferOutstock】wms已下发使用调拨订单{input.transfer_order}!");
|
||||
throw new AppFriendlyException($@"wms已下发使用调拨订单{input.transfer_order}!", 500);
|
||||
}
|
||||
else // 删除数据重新插入
|
||||
{
|
||||
await db.Deleteable<WmsTransferOutstockH>().Where(r => r.id == wmsTransferOutstockHRep.id).ExecuteCommandAsync();
|
||||
await db.Deleteable<WmsTransferOutstockD>().Where(r => r.bill_id == wmsTransferOutstockHRep.id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
if (details_WAREHOUSE_YCL_ID.Count > 0)
|
||||
{
|
||||
|
||||
WmsRawmatTransferoutstockH wmsRawmatTransferoutstockH = new WmsRawmatTransferoutstockH();
|
||||
string code = await _billRuleService.GetBillNumber("RawmatTransferoutstock");
|
||||
wmsRawmatTransferoutstockH.erp_bill_code = input.transfer_order;
|
||||
@@ -1663,25 +1762,6 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
if(details_WAREHOUSE_CP_ID.Count > 0)
|
||||
{
|
||||
// 判断是否重复传输
|
||||
WmsTransferOutstockH wmsTransferOutstockHRep = await db.Queryable<WmsTransferOutstockH>().Where(r => r.erp_pk == input.erp_pk).FirstAsync();
|
||||
if (wmsTransferOutstockHRep != null)
|
||||
{
|
||||
// 判断单据是否已经下发
|
||||
List<WmsTransferOutstockD> _wmsTransferOutstockDs = await db.Queryable<WmsTransferOutstockD>().Where(r => r.bill_id == wmsTransferOutstockHRep.id).ToListAsync();
|
||||
bool isxf = _wmsTransferOutstockDs.Where(r => r.xf_qty > 0).Any();
|
||||
if (isxf)
|
||||
{
|
||||
_LoggerErp2Mes.LogWarning($@"【TransferOutstock】wms已下发使用调拨订单{input.transfer_order}!");
|
||||
throw new AppFriendlyException($@"wms已下发使用调拨订单{input.transfer_order}!", 500);
|
||||
}
|
||||
else // 删除数据重新插入
|
||||
{
|
||||
await db.Deleteable<WmsTransferOutstockH>().Where(r => r.id == wmsTransferOutstockHRep.id).ExecuteCommandAsync();
|
||||
await db.Deleteable<WmsTransferOutstockD>().Where(r => r.bill_id == wmsTransferOutstockHRep.id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
WmsTransferOutstockH wmsTransferOutstockH = new WmsTransferOutstockH();
|
||||
string code = await _billRuleService.GetBillNumber("WmsTransferOutstock");
|
||||
wmsTransferOutstockH.erp_bill_code = input.transfer_order;
|
||||
@@ -1794,7 +1874,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
await db.Ado.BeginTranAsync();
|
||||
// 判断是否重复传输
|
||||
WmsRawmatOutstockH wmsRawmatOutstockHRep = await db.Queryable<WmsRawmatOutstockH>().Where(r => r.erp_pk == input.erp_pk).FirstAsync();
|
||||
WmsRawmatOutstockH wmsRawmatOutstockHRep = await db.Queryable<WmsRawmatOutstockH>().Where(r => r.erp_bill_code == input.outstock_order).FirstAsync();
|
||||
if (wmsRawmatOutstockHRep != null)
|
||||
{
|
||||
// 判断单据是否已经下发
|
||||
|
||||
@@ -147,7 +147,6 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
|
||||
|
||||
|
||||
public WareHouseService(ISqlSugarRepository<WmsInstockH> repository, IDictionaryDataService dictionaryDataService, StackExRedisHelper redisData,
|
||||
IBillRullService billRullService, IUserManager userManager, ICacheManager cacheManager, IElevatorControlService elevatorControlService,
|
||||
IWmsCarryBindService wmsCarryBindService,
|
||||
@@ -421,8 +420,8 @@ namespace Tnb.WarehouseMgr
|
||||
/// <returns></returns>
|
||||
public string[] GetFloor1YCLDBOutstockLocation()
|
||||
{
|
||||
return new string[5] { WmsWareHouseConst.Floor1GLSGWOutstockStation1 , WmsWareHouseConst.Floor1GLSGWOutstockStation2
|
||||
, WmsWareHouseConst.Floor1GLSGWOutstockStation3, WmsWareHouseConst.Floor1GLSGWOutstockStation4, WmsWareHouseConst.Floor1GLSGWOutstockStation5 };
|
||||
return new string[3] { WmsWareHouseConst.Floor1OutstockStation1 , WmsWareHouseConst.Floor1OutstockStation2
|
||||
, WmsWareHouseConst.Floor1OutstockStation3 };
|
||||
}
|
||||
|
||||
|
||||
@@ -1462,6 +1461,21 @@ namespace Tnb.WarehouseMgr
|
||||
.ToList();
|
||||
|
||||
#region 三楼三四号梯如果与判断一托下有冲突
|
||||
|
||||
#region 电梯第三次改动
|
||||
// 到暂存区的未完成任务
|
||||
List<WmsDistaskH> wmsdistasks_agvElevator = await _db.Queryable<WmsDistaskH>()
|
||||
.InnerJoin<BasLocation>((a, b) => a.endlocation_id == b.id)
|
||||
.Where((a, b) => a.status != WmsWareHouseConst.BILLSTATUS_COMPLETE_ID && a.status != WmsWareHouseConst.BILLSTATUS_CANCEL_ID
|
||||
&& b.region_id == WmsWareHouseConst.REGION_CPOutstockCache_ID)
|
||||
.ToListAsync();
|
||||
// 过滤同目标库位的正在执行的预任务
|
||||
agvElevatorTasks = agvElevatorTasks.Where(r => !wmsdistasks_agvElevator.Select(a => a.endlocation_id).Contains(r.endlocation_id)).ToList();
|
||||
// 过滤重复目标库位的预任务
|
||||
agvElevatorTasks = agvElevatorTasks.OrderBy(r => r.endlocation_code).GroupBy(r => r.endlocation_code).Select(r => { return r.ToList()[0]; }).ToList();
|
||||
#endregion
|
||||
|
||||
|
||||
if (s_elevatortaskWCSRequestDic.Count > 0)
|
||||
{
|
||||
for (int index_agvElevatorTasks = 0; index_agvElevatorTasks < agvElevatorTasks.Count; index_agvElevatorTasks++)
|
||||
@@ -1498,6 +1512,7 @@ namespace Tnb.WarehouseMgr
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
var elePreTasks = preTasks.Where(it => it.area_code.Contains("ELE", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||
var normalPreTasks = preTasks.Where(it => it.area_code != "B" && !agvElevatorTasks.Concat(elePreTasks).Select(x => x.endlocation_code).Contains(it.endlocation_code)).ToList();
|
||||
|
||||
@@ -2409,9 +2424,8 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
checkRunDoor++;
|
||||
tuple = await _elevatorControlService.GetElevatorStatus(devName, tags, CancellationToken.None);
|
||||
Logger.Information($"{devName.Match(@"\d+")}#梯 sysStatus:{tuple.sysStatus},runStatus:{tuple.runStatus},当前楼层floorNo:{tuple.floorNo},目标楼层disTask.end_floor={floor}");
|
||||
Logger.Information($"第{checkRunDoor}次 {devName.Match(@"\d+")}#梯 sysStatus:{tuple.sysStatus},runStatus:{tuple.runStatus},当前楼层floorNo:{tuple.floorNo},目标楼层{floor}");
|
||||
|
||||
Logger.Information($"第{checkCloseDoor}次 {devName.Match(@"\d+")}#梯 当前门状态:{doorStatus}");
|
||||
// 180次后重试
|
||||
if (checkRunDoor >= 180)
|
||||
{
|
||||
@@ -2420,7 +2434,7 @@ namespace Tnb.WarehouseMgr
|
||||
await Task.Delay(1000);
|
||||
} while (tuple.sysStatus != 3 || tuple.runStatus != 0 || floor != tuple.floorNo);
|
||||
|
||||
Logger.Information($"结束判断 {devName.Match(@"\d+")}#梯 sysStatus:{tuple.sysStatus},runStatus:{tuple.runStatus},当前楼层floorNo:{tuple.floorNo},目标楼层disTask.end_floor={floor}");
|
||||
Logger.Information($"第{checkRunDoor}次 结束判断 {devName.Match(@"\d+")}#梯 sysStatus:{tuple.sysStatus},runStatus:{tuple.runStatus},当前楼层floorNo:{tuple.floorNo},目标楼层disTask.end_floor={floor}");
|
||||
|
||||
if (tuple.sysStatus.ToEnum<EnumSysStatus>() == EnumSysStatus.正常状态 && tuple.runStatus.ToEnum<EnumRunStatus>() == EnumRunStatus.停梯)
|
||||
{
|
||||
@@ -2557,6 +2571,18 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
try
|
||||
{
|
||||
List<WmsDistaskH> disTasks = await _db.Queryable<WmsDistaskH>().Where(a => input.disTaskIds.Contains(a.id)).ToListAsync();
|
||||
foreach (WmsDistaskH wmsDistaskH in disTasks)
|
||||
{
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.location_id == wmsDistaskH.startlocation_id
|
||||
&& r.carry_code != wmsDistaskH.carry_code).FirstAsync();
|
||||
BasLocation startlocation = await _db.Queryable<BasLocation>().Where(r => r.location_code == wmsDistaskH.startlocation_code).FirstAsync();
|
||||
if (wmsCarryH != null && startlocation.is_type == ((int)(EnumLocationType.存储库位)).ToString())
|
||||
{
|
||||
throw Oops.Bah($"任务单{wmsDistaskH.bill_code}的起点库位{wmsDistaskH.startlocation_code}是存储库位,且已被载具{wmsCarryH.carry_code}占用!");
|
||||
}
|
||||
}
|
||||
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
//更任务执行
|
||||
@@ -2642,11 +2668,28 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task TaskComplate(TaskCompleUpInput input)
|
||||
{
|
||||
List<WmsDistaskH> disTasks = await _db.Queryable<WmsDistaskH>().Where(a => input.disTaskIds.Contains(a.id)).ToListAsync();
|
||||
foreach (WmsDistaskH wmsDistaskH in disTasks)
|
||||
{
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.location_id == wmsDistaskH.endlocation_id && r.carry_code != wmsDistaskH.carry_code).FirstAsync();
|
||||
BasLocation endlocation = await _db.Queryable<BasLocation>().Where(r => r.location_code == wmsDistaskH.endlocation_code).FirstAsync();
|
||||
if (wmsCarryH != null && endlocation.is_type == ((int)(EnumLocationType.存储库位)).ToString())
|
||||
{
|
||||
throw Oops.Bah($"任务单{wmsDistaskH.bill_code}的终点库位{wmsDistaskH.endlocation_code}是存储库位,且已被载具{wmsCarryH.carry_code}占用!");
|
||||
}
|
||||
}
|
||||
|
||||
await TaskComplate(input, _db);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 任务完成
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[NonAction]
|
||||
public async Task TaskComplate(TaskCompleUpInput input, ISqlSugarClient dbConn = null)
|
||||
{
|
||||
var db = dbConn;
|
||||
@@ -3152,67 +3195,68 @@ namespace Tnb.WarehouseMgr
|
||||
BasLocation endlocation = await _db.Queryable<BasLocation>().InnerJoin<WmsPointH>((a, b) => a.id == b.location_id).Where((a, b) => b.id == pEndId).FirstAsync();
|
||||
|
||||
// 后续可整理成配置表
|
||||
// 3-1
|
||||
if (startlocation.wh_id == WmsWareHouseConst.WAREHOUSE_CP_ID && endlocation.wh_id == WmsWareHouseConst.WAREHOUSE_CPCRK_ID)
|
||||
{
|
||||
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", "");
|
||||
#region 第二次改动弃用
|
||||
//if (startlocation.wh_id == WmsWareHouseConst.WAREHOUSE_CP_ID && endlocation.wh_id == WmsWareHouseConst.WAREHOUSE_CPCRK_ID)
|
||||
//{
|
||||
// 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.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)
|
||||
{
|
||||
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();
|
||||
}
|
||||
// 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.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)
|
||||
// {
|
||||
// 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);
|
||||
}
|
||||
// if (locations.Count == 0)
|
||||
// {
|
||||
// throw new AppFriendlyException($"三楼发货时,没有可用的暂存库位可以使用", 500);
|
||||
// }
|
||||
|
||||
BasLocation cache_location = locations.First();
|
||||
// 到暂存区
|
||||
points.Add(wmsPointHs.Where(r => r.id == pStartId).First());
|
||||
points.Add(wmsPointHs.Where(r => r.location_code == cache_location.location_code).First());
|
||||
// 到电梯
|
||||
WmsPointH cacheOut_point = wmsPointHs.Where(r => r.location_code == cache_location.location_code).First().Copy();
|
||||
WmsPointH DT_C_point = wmsPointHs.Where(r => r.point_code == $"DT-C-03-0{elevatorSno}").First().Copy();
|
||||
cacheOut_point.area_code = "FC";
|
||||
DT_C_point.area_code = "FC";
|
||||
// BasLocation cache_location = locations.First();
|
||||
// // 到暂存区
|
||||
// points.Add(wmsPointHs.Where(r => r.id == pStartId).First());
|
||||
// points.Add(wmsPointHs.Where(r => r.location_code == cache_location.location_code).First());
|
||||
// // 到电梯
|
||||
// WmsPointH cacheOut_point = wmsPointHs.Where(r => r.location_code == cache_location.location_code).First().Copy();
|
||||
// WmsPointH DT_C_point = wmsPointHs.Where(r => r.point_code == $"DT-C-03-0{elevatorSno}").First().Copy();
|
||||
// cacheOut_point.area_code = "FC";
|
||||
// DT_C_point.area_code = "FC";
|
||||
|
||||
points.Add(cacheOut_point);
|
||||
points.Add(DT_C_point);
|
||||
// 到一楼
|
||||
points.Add(wmsPointHs.Where(r => r.point_code == $"DT-3-{elevatorSno}").First());
|
||||
points.Add(wmsPointHs.Where(r => r.point_code == $"DT-1-{elevatorSno}").First());
|
||||
points.Add(wmsPointHs.Where(r => r.point_code == $"DT-R-01-0{elevatorSno}").First());
|
||||
points.Add(wmsPointHs.Where(r => r.id == pEndId).First());
|
||||
}
|
||||
// points.Add(cacheOut_point);
|
||||
// points.Add(DT_C_point);
|
||||
// // 到一楼
|
||||
// points.Add(wmsPointHs.Where(r => r.point_code == $"DT-3-{elevatorSno}").First());
|
||||
// points.Add(wmsPointHs.Where(r => r.point_code == $"DT-1-{elevatorSno}").First());
|
||||
// points.Add(wmsPointHs.Where(r => r.point_code == $"DT-R-01-0{elevatorSno}").First());
|
||||
// points.Add(wmsPointHs.Where(r => r.id == pEndId).First());
|
||||
//}
|
||||
#endregion
|
||||
//1-3
|
||||
else if (startlocation.wh_id == WmsWareHouseConst.WAREHOUSE_CPCRK_ID && endlocation.wh_id == WmsWareHouseConst.WAREHOUSE_CP_ID)
|
||||
if (startlocation.wh_id == WmsWareHouseConst.WAREHOUSE_CPCRK_ID && endlocation.wh_id == WmsWareHouseConst.WAREHOUSE_CP_ID)
|
||||
{
|
||||
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", "");
|
||||
@@ -3270,11 +3314,11 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
|
||||
|
||||
Logger.Information($"起点{startlocation.location_code} 终点{endlocation.location_code} 获取到路径 {JsonConvert.SerializeObject(points)}");
|
||||
if (points.Count < 6)
|
||||
{
|
||||
throw new AppFriendlyException($"路径错误,需要检查路径配置{JsonConvert.SerializeObject(points)}", 500);
|
||||
}
|
||||
//Logger.Information($"起点{startlocation.location_code} 终点{endlocation.location_code} 获取到路径 {JsonConvert.SerializeObject(points)}");
|
||||
//if (points.Count < 6)
|
||||
//{
|
||||
// throw new AppFriendlyException($"路径错误,需要检查路径配置{JsonConvert.SerializeObject(points)}", 500);
|
||||
//}
|
||||
|
||||
//List<WmsRoad> wmsRoads = await _db.Queryable<WmsRoad>().Where(r => r.startpoint_id == pStartId).ToListAsync();
|
||||
//if (wmsRoads?.FindAll(x => x.endpoint_code != null && x.location_code.Contains("dt", StringComparison.OrdinalIgnoreCase))?.Count > 0)
|
||||
|
||||
@@ -114,6 +114,8 @@ namespace Tnb.WarehouseMgr
|
||||
mod = minPacking.Value - extra;
|
||||
}
|
||||
|
||||
|
||||
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().Where(r => r.id == WmsOutsourceD.matcode_id).FirstAsync();
|
||||
for (int j = 0; j < codeNum; j++)
|
||||
{
|
||||
int index = j + 1;
|
||||
@@ -133,7 +135,7 @@ namespace Tnb.WarehouseMgr
|
||||
material_code = WmsOutsourceD.matcode,
|
||||
barcode = code,
|
||||
code_batch = WmsOutsourceD.code_batch,
|
||||
material_specification = WmsOutsourceD.matspecification,
|
||||
material_specification = basMaterial.material_specification,
|
||||
codeqty = minPacking,
|
||||
unit_id = WmsOutsourceD.unit,
|
||||
is_lock = 0,
|
||||
@@ -142,7 +144,8 @@ namespace Tnb.WarehouseMgr
|
||||
require_code = WmsOutsourceH.outsource_order,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
required_type = WmsWareHouseConst.BILLTYPE_OUTSOURCE_ID
|
||||
required_type = WmsWareHouseConst.BILLTYPE_OUTSOURCE_ID,
|
||||
material_name = basMaterial.name
|
||||
};
|
||||
if (index == codeNum)
|
||||
barCode.codeqty = mod == 0 ? minPacking : mod;
|
||||
|
||||
@@ -353,6 +353,7 @@ namespace Tnb.WarehouseMgr
|
||||
mod = minPacking.Value - extra;
|
||||
}
|
||||
|
||||
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().Where(r => r.id == WmsPurchaseD.material_id).FirstAsync();
|
||||
for (int j = 0; j < codeNum; j++)
|
||||
{
|
||||
int index = j + 1;
|
||||
@@ -370,7 +371,7 @@ namespace Tnb.WarehouseMgr
|
||||
material_code = WmsPurchaseD.material_code,
|
||||
barcode = code,
|
||||
code_batch = WmsPurchaseD.code_batch,
|
||||
material_specification = WmsPurchaseD.material_specification,
|
||||
material_specification = basMaterial.material_specification,
|
||||
container_no = WmsPurchaseD.container_no,
|
||||
codeqty = minPacking,
|
||||
unit_id = WmsPurchaseD.unit_id,
|
||||
@@ -380,7 +381,9 @@ namespace Tnb.WarehouseMgr
|
||||
require_code = WmsPurchaseH.bill_code,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
required_type = WmsWareHouseConst.BILLTYPE_PURCHASE_ID
|
||||
required_type = WmsWareHouseConst.BILLTYPE_PURCHASE_ID,
|
||||
material_name = basMaterial.name,
|
||||
supplier_name = WmsPurchaseH.supplier_name
|
||||
};
|
||||
if (index == codeNum)
|
||||
barCode.codeqty = mod == 0 ? minPacking : mod;
|
||||
|
||||
@@ -21,6 +21,7 @@ using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Attributes;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
@@ -33,8 +34,10 @@ namespace Tnb.WarehouseMgr
|
||||
/// 材料出库单
|
||||
/// </summary>
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WmsRawmatOutstock_ID)]
|
||||
[ServiceModule(BizTypeId)]
|
||||
public class WmsRawmatOutstockService : BaseWareHouseService
|
||||
{
|
||||
private const string BizTypeId = WmsWareHouseConst.BIZTYPE_WmsRawmatOutstock_ID;
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IBillRullService _billRullService;
|
||||
|
||||
@@ -240,6 +240,8 @@ namespace Tnb.WarehouseMgr
|
||||
mod = minPacking.Value - extra;
|
||||
}
|
||||
|
||||
|
||||
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().Where(r => r.id == WmsRawmatTransferinstockD.matcode_id).FirstAsync();
|
||||
for (int j = 0; j < codeNum; j++)
|
||||
{
|
||||
int index = j + 1;
|
||||
@@ -258,7 +260,7 @@ namespace Tnb.WarehouseMgr
|
||||
material_code = WmsRawmatTransferinstockD.matcode,
|
||||
barcode = code,
|
||||
code_batch = WmsRawmatTransferinstockD.code_batch,
|
||||
material_specification = WmsRawmatTransferinstockD.matspecification,
|
||||
material_specification = basMaterial.material_specification,
|
||||
codeqty = minPacking,
|
||||
unit_id = WmsRawmatTransferinstockD.unit,
|
||||
is_lock = 0,
|
||||
@@ -267,7 +269,8 @@ namespace Tnb.WarehouseMgr
|
||||
require_code = WmsRawmatTransferinstockH.bill_code,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
required_type = WmsWareHouseConst.BILLTYPE_RAWMATTRANSFERINSTOCK_ID
|
||||
required_type = WmsWareHouseConst.BILLTYPE_RAWMATTRANSFERINSTOCK_ID,
|
||||
material_name = basMaterial.name
|
||||
};
|
||||
if (index == codeNum)
|
||||
barCode.codeqty = mod == 0 ? minPacking : mod;
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 下发
|
||||
/// 下发 电梯第三次改动
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
@@ -179,7 +179,6 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
Logger.LogInformation($"【Distribute】 预计生成{items_pretask.Count}条预任务");
|
||||
|
||||
|
||||
List<BasLocation> endLocations = null;
|
||||
// 自动发货
|
||||
if (!input.isManual)
|
||||
@@ -223,12 +222,24 @@ namespace Tnb.WarehouseMgr
|
||||
// 自动发货
|
||||
if (!input.isManual)
|
||||
{
|
||||
endLocation = await _db.Queryable<BasLocation>().Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync();
|
||||
|
||||
if (endLocation == null)
|
||||
#region 电梯第三次改动 延迟预任务生成
|
||||
// 3-1 第三次改动
|
||||
var YCLInnerTransfer = await _db.Queryable<BasFactoryConfig>().Where(p => p.key == "floor3CurInCacheLocation").FirstAsync();
|
||||
Logger.Information($"当前发货区: {YCLInnerTransfer.value}");
|
||||
if (YCLInnerTransfer.value == null || (YCLInnerTransfer.value != "3楼发货左" && YCLInnerTransfer.value != "3楼发货右"))
|
||||
{
|
||||
throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500);
|
||||
throw new AppFriendlyException($"工厂配置->三楼出库暂存区当前入库分区 项配置错误!需要配置值为【3楼发货左】或【3楼发货右】", 500);
|
||||
}
|
||||
List<BasLocation> locations = await _db.Queryable<BasLocation>()
|
||||
.InnerJoin<WmsElevatorcacheArea>((a, b) => a.id == b.location_id)
|
||||
.Where((a, b) => b.name == YCLInnerTransfer.value).OrderBy("a.location_code,a.is_lock,a.is_use,task_nums").ToListAsync();
|
||||
|
||||
endLocation = locations.FirstOrDefault();
|
||||
|
||||
await _db.Updateable<BasFactoryConfig>().SetColumns(r => r.value == (YCLInnerTransfer.value == "3楼发货左" ? "3楼发货右" : "3楼发货左"))
|
||||
.Where(r => r.key == "floor3CurInCacheLocation").ExecuteCommandAsync();
|
||||
|
||||
#endregion
|
||||
}
|
||||
//人工发货
|
||||
else
|
||||
@@ -257,6 +268,7 @@ namespace Tnb.WarehouseMgr
|
||||
throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||
}
|
||||
|
||||
|
||||
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocation.id);
|
||||
|
||||
if (ePoint != null)
|
||||
@@ -281,10 +293,10 @@ namespace Tnb.WarehouseMgr
|
||||
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);
|
||||
}
|
||||
//if (points.Count <= 2)
|
||||
//{
|
||||
// throw new AppFriendlyException($"sPoint {sPoint.point_code} ePoint{ePoint.point_code}该路径不存在", 500);
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -342,7 +354,9 @@ namespace Tnb.WarehouseMgr
|
||||
carry_status = ((int)EnumCarryStatus.占用).ToString(),
|
||||
is_lock = 1,
|
||||
location_id = startLocation.id,
|
||||
location_code = location.location_code
|
||||
location_code = location.location_code,
|
||||
require_id = input.source_id,
|
||||
biz_type = WmsWareHouseConst.BIZTYPE_WMSSALERELEASE_ID
|
||||
}).Where(it => it.id == carry.id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
@@ -416,6 +430,287 @@ namespace Tnb.WarehouseMgr
|
||||
return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 下发
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
//[HttpPost, NonUnify, AllowAnonymous]
|
||||
//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);
|
||||
// }
|
||||
// if (string.IsNullOrEmpty(input.source_id))
|
||||
// {
|
||||
// throw new AppFriendlyException("来源单据id不可为空", 500);
|
||||
// }
|
||||
|
||||
// WmsSaleD wmsOutstockD = await _db.Queryable<WmsSaleD>().FirstAsync(it => it.id == input.source_id);
|
||||
// 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 };
|
||||
// List<Tuple<string, WmsCarryH, WmsCarryCode, BasLocation>> items = await _wareHouseService.OutStockStrategy_saleRelease(outStockStrategyInput);
|
||||
|
||||
// decimal canOutstockQty = items.Sum(r => r.Item3.codeqty).ParseToDecimal();
|
||||
// if (canOutstockQty < input.qty)
|
||||
// {
|
||||
// throw new AppFriendlyException($@"当前可出库数量只有 {canOutstockQty.ToString("G")}", 500);
|
||||
// }
|
||||
|
||||
// List<Tuple<string, WmsCarryH, WmsCarryCode, BasLocation>> items_sorttask = items.Where(r => r.Item1 == "分拣任务").ToList();
|
||||
// List<Tuple<string, WmsCarryH, WmsCarryCode, BasLocation>> items_pretask = items.Where(r => r.Item1 == "预任务").ToList();
|
||||
|
||||
// Logger.LogInformation($"【Distribute】 预计生成{items_pretask.Count}条预任务");
|
||||
|
||||
|
||||
// List<BasLocation> endLocations = null;
|
||||
// // 自动发货
|
||||
// if (!input.isManual)
|
||||
// {
|
||||
// endLocations = await _db.Queryable<BasLocation>().Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").ToListAsync();
|
||||
|
||||
// if (endLocations.Count < items_pretask.Count)
|
||||
// {
|
||||
// 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
|
||||
// {
|
||||
// InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, Size = items_pretask.Count, Region_id = WmsWareHouseConst.REGION_CPManualOutstock_ID };
|
||||
// endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
|
||||
// if (endLocations.Count < items_pretask.Count)
|
||||
// {
|
||||
// throw new AppFriendlyException("三楼人工出库区没有足够的未锁定且空闲的出库工位", 500);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// // 预任务逻辑
|
||||
// foreach (Tuple<string, WmsCarryH, WmsCarryCode, BasLocation> item in items_pretask)
|
||||
// {
|
||||
// WmsCarryH carry = item.Item2;
|
||||
// WmsCarryCode carryCode = item.Item3;
|
||||
// BasLocation startLocation = item.Item4;
|
||||
// // 根据一楼工位任务数平均分配任务 确定一楼工位
|
||||
|
||||
// BasLocation endLocation = null;
|
||||
// // 自动发货
|
||||
// if (!input.isManual)
|
||||
// {
|
||||
// endLocation = await _db.Queryable<BasLocation>().Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync();
|
||||
|
||||
// if (endLocation == null)
|
||||
// {
|
||||
// throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500);
|
||||
// }
|
||||
// }
|
||||
// //人工发货
|
||||
// else
|
||||
// {
|
||||
// InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, Size = 1, Region_id = WmsWareHouseConst.REGION_CPManualOutstock_ID };
|
||||
// endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
|
||||
|
||||
// if (endLocations.Count < 1)
|
||||
// {
|
||||
// throw new AppFriendlyException("三楼人工出库区没有足够的未锁定且空闲的出库工位", 500);
|
||||
// }
|
||||
// endLocation = endLocations[0];
|
||||
// }
|
||||
// if (endLocation == null)
|
||||
// {
|
||||
// throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500);
|
||||
// }
|
||||
// WmsPointH sPoint = null!;
|
||||
// WmsPointH ePoint = null!;
|
||||
|
||||
// sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == startLocation.id);
|
||||
|
||||
// bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, endLocation);
|
||||
// if (!isMatch)
|
||||
// {
|
||||
// throw new AppFriendlyException("库位与载具规格不匹配", 500);
|
||||
// }
|
||||
|
||||
// ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == endLocation.id);
|
||||
|
||||
// if (ePoint != null)
|
||||
// {
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new AppFriendlyException($"库位{endLocation.location_code}未在点位表中维护对应点位", 500);
|
||||
// }
|
||||
|
||||
// string endLocationId = endLocation.id;
|
||||
|
||||
// // 在线开发
|
||||
// //VisualDevEntity? templateEntity = await _visualDevService?.GetInfoById(ModuleConsts.MODULE_WMSDELIVERYPDA_ID, true)!;
|
||||
// //await _runService.Create(templateEntity, input);
|
||||
|
||||
// // 计算路径,插入预任务申请
|
||||
|
||||
// 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)
|
||||
// {
|
||||
// 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_WMSSALERELEASE_ID,
|
||||
// task_type = WmsWareHouseConst.WMS_PRETASK_TRANSFER_TYPE_ID
|
||||
// };
|
||||
// preTask.carry_id = carry.id;
|
||||
// preTask.carry_code = carry.carry_code;
|
||||
// preTask.area_id = sPoint?.area_id!;
|
||||
// preTask.area_code = it.Key;
|
||||
// preTask.require_id = input.source_id;
|
||||
// preTask.require_code = "";
|
||||
// preTask.create_id = _userManager.UserId;
|
||||
// preTask.create_time = DateTime.Now;
|
||||
// return preTask;
|
||||
// }).ToList();
|
||||
// bool isOk = await _wareHouseService.GenPreTask(preTasks, null!, _db);
|
||||
// if (isOk)
|
||||
// {
|
||||
// if (endLocationId != null)
|
||||
// {
|
||||
// //查询库位表
|
||||
// BasLocation location = await _db.Queryable<BasLocation>().SingleAsync(it => it.id == startLocation.id);
|
||||
// {
|
||||
// //载具加锁,增加库位信息
|
||||
// _ = await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH
|
||||
// {
|
||||
// carry_status = ((int)EnumCarryStatus.占用).ToString(),
|
||||
// is_lock = 1,
|
||||
// location_id = startLocation.id,
|
||||
// location_code = location.location_code,
|
||||
// require_id = input.source_id,
|
||||
// biz_type = WmsWareHouseConst.BIZTYPE_WMSSALERELEASE_ID
|
||||
// }).Where(it => it.id == carry.id).ExecuteCommandAsync();
|
||||
// }
|
||||
|
||||
// //所有库位加锁
|
||||
// string?[] ids = new[] { startLocation.id, preTasks[0].endlocation_id, endLocationId };
|
||||
// _ = await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_lock = 1 }).Where(it => ids.Contains(it.id)).ExecuteCommandAsync();
|
||||
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// Logger.LogInformation($"【Distribute】 预计生成{items_sorttask.Count}条分拣任务");
|
||||
// // 分拣任务逻辑
|
||||
// foreach (Tuple<string, WmsCarryH, WmsCarryCode, BasLocation> item in items_sorttask)
|
||||
// {
|
||||
// WmsCarryH carry = item.Item2;
|
||||
// WmsCarryCode carryCode = item.Item3;
|
||||
// BasLocation startLocation = item.Item4;
|
||||
|
||||
// // 锁定分拣载具
|
||||
// await _db.Updateable<WmsCarryH>().SetColumns(r => r.is_lock == 1).Where(r => r.id == carry.id).ExecuteCommandAsync();
|
||||
|
||||
// Dictionary<string, object> dic = new()
|
||||
// {
|
||||
// [nameof(WmsSortingtask.id)] = SnowflakeIdHelper.NextId(),
|
||||
// [nameof(WmsSortingtask.bill_code)] = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_SORTINGTASK_ENCODE),
|
||||
// [nameof(WmsSortingtask.org_id)] = input.org_id ?? _userManager.User.OrganizeId,
|
||||
// [nameof(WmsSortingtask.qty)] = carryCode.codeqty,
|
||||
// [nameof(WmsSortingtask.carry_id)] = carry.id,
|
||||
// [nameof(WmsSortingtask.carry_code)] = carry.carry_code,
|
||||
// [nameof(WmsSortingtask.status)] = WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID,
|
||||
// [nameof(WmsSortingtask.location_id)] = startLocation.id,
|
||||
// [nameof(WmsSortingtask.location_code)] = startLocation.location_code,
|
||||
// [nameof(WmsSortingtask.create_id)] = input.create_id ?? _userManager.UserId,
|
||||
// [nameof(WmsSortingtask.create_time)] = DateTime.Now,
|
||||
// [nameof(WmsSortingtask.source_id)] = input.source_id
|
||||
// };
|
||||
|
||||
// VisualDevModelDataCrInput visualDevModelDataCrInput = new()
|
||||
// {
|
||||
// data = dic
|
||||
// };
|
||||
|
||||
// //在线开发
|
||||
// VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSSORTINGTASK_ID, false);
|
||||
// await _runService.Create(templateEntity, visualDevModelDataCrInput);
|
||||
// }
|
||||
|
||||
// // 更新销售出库单子表已下发数量
|
||||
// await _db.Updateable<WmsSaleD>().SetColumns(r => r.purchase_arriveqty == r.purchase_arriveqty + input.qty).Where(r => r.id == input.source_id).ExecuteCommandAsync();
|
||||
|
||||
// await _db.Ado.CommitTranAsync();
|
||||
// Logger.LogInformation($"【Distribute】 销售出库下发完成");
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await _db.Ado.RollbackTranAsync();
|
||||
// Logger.LogError($"【Distribute】 销售出库 {ex.Message}");
|
||||
// Logger.LogError($"【Distribute】 销售出库 {ex.StackTrace}");
|
||||
// return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// semaphoreSlim.Release();
|
||||
// await InvokeGenPretaskExcute();
|
||||
// }
|
||||
|
||||
// return await ToApiResult(HttpStatusCode.OK, "成功");
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 分拣
|
||||
/// </summary>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//Dm
|
||||
//"DefaultConnection": "server={0};port={1};database={2};uid={3};pwd={4};"
|
||||
//Oracle
|
||||
//"DefaultConnection": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST={0})(PORT={1}))(CONNECT_DATA=(SERVER = DEDICATED)(SERVICE_NAME={2})));User Id={3};Password={4}"
|
||||
//"DefaultConnection": "Data Sourctianyi20240902e=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST={0})(PORT={1}))(CONNECT_DATA=(SERVER = DEDICATED)(SERVICE_NAME={2})));User Id={3};Password={4}"
|
||||
//PostgreSQL
|
||||
"DefaultConnection": "server={0};port={1};database={2};uid={3};pwd={4};pooling=true;KeepAlive=60;ConnectionLifetime=300;MaxPoolSize=320;",
|
||||
//MySql
|
||||
|
||||
Reference in New Issue
Block a user