@ -14,6 +14,8 @@ using SlnMesnac.Model.Enum;
using HslCommunication.Enthernet ;
using HslCommunication.Enthernet ;
using System.Threading ;
using System.Threading ;
using SlnMesnac.TouchSocket.Entity ;
using SlnMesnac.TouchSocket.Entity ;
using SlnMesnac.Model.AirportApiEntity ;
using System.Linq ;
namespace SlnMesnac.Business.@base
namespace SlnMesnac.Business.@base
{
{
@ -26,7 +28,13 @@ namespace SlnMesnac.Business.@base
private ILogger < BaseTaskInfoBusiness > _logger ;
private ILogger < BaseTaskInfoBusiness > _logger ;
private IAirportTaskService _Taskservice ;
private IAirportTaskService _Taskservice ;
private IAGVStateService _AGVStateService ;
private IAGVStateService _AGVStateService ;
public BaseTaskInfoBusiness ( ILogger < BaseTaskInfoBusiness > logger , IAirportTaskService Taskservice , IAGVStateService agvService , TcpServer tcpServer )
private AirPorthttpClient _airpttpClient ;
public BaseTaskInfoBusiness (
ILogger < BaseTaskInfoBusiness > logger ,
IAirportTaskService Taskservice ,
IAGVStateService agvService ,
TcpServer tcpServer ,
AirPorthttpClient airPorthttpClient )
{
{
_logger = logger ;
_logger = logger ;
_tcpServer = tcpServer ;
_tcpServer = tcpServer ;
@ -34,9 +42,45 @@ namespace SlnMesnac.Business.@base
_tcpServer . ReceiveStackWorkDoneEvent + = _tcpServer_StackWorkDoneEvent ;
_tcpServer . ReceiveStackWorkDoneEvent + = _tcpServer_StackWorkDoneEvent ;
_Taskservice = Taskservice ;
_Taskservice = Taskservice ;
_AGVStateService = agvService ;
_AGVStateService = agvService ;
_airpttpClient = airPorthttpClient ;
InitClearTimer ( ) ;
InitClearTimer ( ) ;
//doWhileGetAGVTaskInfo();
//doWhileGetAGVTaskInfo();
}
}
public static BaseTaskInfoBusiness GetInstance (
ILogger < BaseTaskInfoBusiness > logger ,
IAirportTaskService Taskservice ,
IAGVStateService agvService ,
TcpServer tcpServer ,
AirPorthttpClient airPorthttpClient )
{
if ( instance = = null )
{
instance = new BaseTaskInfoBusiness ( logger , Taskservice , agvService , tcpServer , airPorthttpClient ) ;
}
return instance ;
}
/// <summary>
/// 调用接口更新指定的任务状态
/// </summary>
/// <param name="request"></param>
public void RefreshTaskStateForResopnse ( AGVRequestTaskStateDetailEntity request )
{
AGVResponseEntity < ResponseTaskStateDetailDataEntity > response = _airpttpClient . AGVGetTaskStateDetailRequest ( request ) ;
if ( response . code = = 1 )
{
_logger . LogError ( "返回错误:" + response . message ) ;
return ;
}
if ( response . code = = 0 )
{
AirportTask record = new AirportTask ( ) ;
List < AirportTask > list = _Taskservice . GetTaskInfos ( ) ;
//list.Where(x => x.taskno == response.Data
}
}
/// <summary>
/// <summary>
/// 一次码垛完成,发送码垛结果
/// 一次码垛完成,发送码垛结果
/// </summary>
/// </summary>
@ -102,15 +146,6 @@ namespace SlnMesnac.Business.@base
}
}
}
}
public static BaseTaskInfoBusiness GetInstance ( ILogger < BaseTaskInfoBusiness > logger , IAirportTaskService Taskservice , IAGVStateService agvService , TcpServer tcpServer )
{
if ( instance = = null )
{
instance = new BaseTaskInfoBusiness ( logger , Taskservice , agvService , tcpServer ) ;
}
return instance ;
}
private void doWhileGetAGVTaskInfo ( )
private void doWhileGetAGVTaskInfo ( )
{
{
try
try
@ -160,7 +195,7 @@ namespace SlnMesnac.Business.@base
foreach ( var TaskItem in Task )
foreach ( var TaskItem in Task )
{
{
//AGV未派发, AMR未派发
//AGV未派发, AMR未派发
if ( string . IsNullOrEmpty ( TaskItem . agvno) & & string . IsNullOrEmpty ( TaskItem . manipulator no) )
if ( string . IsNullOrEmpty ( TaskItem . deliver agvno) & & string . IsNullOrEmpty ( TaskItem . amragv no) )
{
{
_RefreshLogMessageAction ? . Invoke ( $"正在为AGV, AMR分配任务..." ) ;
_RefreshLogMessageAction ? . Invoke ( $"正在为AGV, AMR分配任务..." ) ;
_logger . LogInformation ( $"正在为AGV, AMR分配任务" ) ;
_logger . LogInformation ( $"正在为AGV, AMR分配任务" ) ;
@ -170,7 +205,7 @@ namespace SlnMesnac.Business.@base
//查询机械臂状态
//查询机械臂状态
}
}
//AGV已派发, AMR未派发
//AGV已派发, AMR未派发
if ( ! string . IsNullOrEmpty ( TaskItem . agvno) & & string . IsNullOrEmpty ( TaskItem . manipulator no) )
if ( ! string . IsNullOrEmpty ( TaskItem . deliver agvno) & & string . IsNullOrEmpty ( TaskItem . amragv no) )
{
{
//查询AMR状态
//查询AMR状态
CreateAMRTask ( TaskItem ) ;
CreateAMRTask ( TaskItem ) ;
@ -179,7 +214,7 @@ namespace SlnMesnac.Business.@base
_logger . LogInformation ( $"正在为AMR分配任务" ) ;
_logger . LogInformation ( $"正在为AMR分配任务" ) ;
}
}
//AGV未派发, AMR已派发
//AGV未派发, AMR已派发
if ( string . IsNullOrEmpty ( TaskItem . agvno) & & ! string . IsNullOrEmpty ( TaskItem . manipulator no) )
if ( string . IsNullOrEmpty ( TaskItem . deliver agvno) & & ! string . IsNullOrEmpty ( TaskItem . amragv no) )
{
{
_RefreshLogMessageAction ? . Invoke ( $"正在为AGV分配任务..." ) ;
_RefreshLogMessageAction ? . Invoke ( $"正在为AGV分配任务..." ) ;
@ -232,7 +267,7 @@ namespace SlnMesnac.Business.@base
_AGVStateService . UpdateAsync ( AgvItem ) ;
_AGVStateService . UpdateAsync ( AgvItem ) ;
//更新任务信息表状态为执行中
//更新任务信息表状态为执行中
AirportTask . manipulator no = AgvItem . agvno ;
AirportTask . amragv no = AgvItem . agvno ;
AirportTask . taskstate = "执行中" ;
AirportTask . taskstate = "执行中" ;
_Taskservice . UpdateTaskAsync ( AirportTask ) ;
_Taskservice . UpdateTaskAsync ( AirportTask ) ;
break ;
break ;
@ -257,7 +292,7 @@ namespace SlnMesnac.Business.@base
try
try
{
{
iflag = true ;
iflag = true ;
List < AGVState > State = GetAgvState ( AgvType . AGV ) ;
List < AGVState > State = GetAgvState ( AgvType . Deliver ) ;
foreach ( var AgvItem in State )
foreach ( var AgvItem in State )
{
{
//根据规则筛选最优AGV
//根据规则筛选最优AGV
@ -276,7 +311,7 @@ namespace SlnMesnac.Business.@base
_AGVStateService . UpdateAsync ( AgvItem ) ;
_AGVStateService . UpdateAsync ( AgvItem ) ;
//更新任务信息表状态为执行中
//更新任务信息表状态为执行中
AirportTask . agvno = AgvItem . agvno ;
AirportTask . deliver agvno = AgvItem . agvno ;
AirportTask . taskstate = "执行中" ;
AirportTask . taskstate = "执行中" ;
_Taskservice . UpdateTaskAsync ( AirportTask ) ;
_Taskservice . UpdateTaskAsync ( AirportTask ) ;
break ;
break ;
@ -290,6 +325,7 @@ namespace SlnMesnac.Business.@base
return iflag ;
return iflag ;
}
}
}
}
/// <summary>
/// <summary>
/// 获取agv设备状态
/// 获取agv设备状态
/// </summary>
/// </summary>