取消定时服务发布订阅模式改为存时间轮询方式
This commit is contained in:
@@ -17,6 +17,7 @@ using JNPF.Systems.Interfaces.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
//using NPOI.SS.Formula.Functions;
|
||||
using SqlSugar;
|
||||
@@ -47,6 +48,7 @@ namespace Tnb.WarehouseMgr
|
||||
private readonly ICacheManager _cacheManager;
|
||||
private readonly IElevatorControlService _elevatorControlService;
|
||||
private static Dictionary<string, object> _elevatorMap = new Dictionary<string, object>();
|
||||
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>();
|
||||
public Func<string, Task> AddUnExecuteTask { get; set; }
|
||||
|
||||
public WareHouseService(ISqlSugarRepository<WmsInstockH> repository, IDictionaryDataService dictionaryDataService,
|
||||
@@ -224,10 +226,10 @@ namespace Tnb.WarehouseMgr
|
||||
var db = _db.CopyNew();
|
||||
try
|
||||
{
|
||||
if (_elevatorMap.Count < 1)
|
||||
{
|
||||
_elevatorMap = await _db.Queryable<WmsElevatorH>().ToDictionaryAsync(x => x.elevator_id, x => x.elevator_code);
|
||||
}
|
||||
//if (_elevatorMap.Count < 1)
|
||||
//{
|
||||
// _elevatorMap = await _db.Queryable<WmsElevatorH>().ToDictionaryAsync(x => x.elevator_id, x => x.elevator_code);
|
||||
//}
|
||||
//获取所有未下发的预任务申请
|
||||
var preTasks = await db.Queryable<WmsPretaskH>().InnerJoin<WmsCarryH>((a, b) => a.startlocation_id == b.location_id && a.carry_id == b.id)
|
||||
.InnerJoin<WmsAreaH>((a, b, c) => a.area_id == c.id)
|
||||
@@ -385,9 +387,9 @@ namespace Tnb.WarehouseMgr
|
||||
try
|
||||
{
|
||||
var item = endLocCodes.FirstOrDefault();
|
||||
if (_elevatorMap.ContainsKey(item.device_id))
|
||||
//if (_elevatorMap.ContainsKey(item.device_id))
|
||||
var devName = _eleCtlCfg.DevName;
|
||||
{
|
||||
var devName = _elevatorMap[item.device_id].ToString();
|
||||
var agvStatus = await _elevatorControlService.GetTagAsync(devName, ElevatorConsts.AGVControl);
|
||||
//判断当前设备是否为运行状态,不是则进入Agv电梯控制状态
|
||||
if (agvStatus.ToEnum<EnumAgvStatus>() != EnumAgvStatus.AGV运行状态)
|
||||
@@ -403,16 +405,15 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
distask_id = disTaskId,
|
||||
elevator_id = devId,
|
||||
elevator_code = _elevatorMap[devId].ToString(),
|
||||
elevator_code = devName,
|
||||
floor = floorN, //5代表4楼
|
||||
task_status = "待执行",
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now
|
||||
};
|
||||
var elevatorQueue = await _db.Queryable<WmsElevatorUnexecute>().Where(it => it.elevator_id == devId && it.task_status == "执行中").ToListAsync();
|
||||
if (_elevatorMap.ContainsKey(devId) && (elevatorQueue.IsNull() || elevatorQueue.Count < 1))
|
||||
if ((elevatorQueue.IsNull() || elevatorQueue.Count < 1))
|
||||
{
|
||||
var devName = _elevatorMap[devId].ToString();
|
||||
elevatorQueueItem.task_status = "执行中";
|
||||
await _elevatorControlService.CallLift(devName, 5, CancellationToken.None);
|
||||
|
||||
@@ -485,6 +486,8 @@ namespace Tnb.WarehouseMgr
|
||||
tuple = await _elevatorControlService.GetElevatorStatus(elevatorQueueItem.elevator_code, CancellationToken.None);
|
||||
} while (tuple.sysStatus != 3 && tuple.runStatus != 0 && tuple.floorNo != disTask.end_floor.ParseToInt());
|
||||
|
||||
Log.Information($"sysStatus:{tuple.sysStatus},runStatus:{tuple.runStatus},floorNo:{tuple.floorNo}");
|
||||
|
||||
if (tuple.sysStatus.ToEnum<EnumSysStatus>() == EnumSysStatus.正常状态 && tuple.runStatus.ToEnum<EnumRunStatus>() == EnumRunStatus.停梯
|
||||
&& tuple.floorNo == disTask.end_floor.ParseToInt())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user