|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using SlnMesnac.Model.AirportApiEntity;
|
|
|
|
|
using SlnMesnac.Repository.service;
|
|
|
|
|
using SlnMesnac.TouchSocket;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace SlnMesnac.Business.@base
|
|
|
|
|
{
|
|
|
|
|
public class BaseStateRefreshBusiness
|
|
|
|
|
{
|
|
|
|
|
private IAGVStateService _AGVStateService;
|
|
|
|
|
private ILogger<BaseStateRefreshBusiness> _logger;
|
|
|
|
|
private static BaseStateRefreshBusiness instance;
|
|
|
|
|
private AirPorthttpClient _airPorthttpClient;
|
|
|
|
|
|
|
|
|
|
public BaseStateRefreshBusiness(ILogger<BaseStateRefreshBusiness> logger, IAGVStateService agvService, AirPorthttpClient airPorthttpClient)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_AGVStateService = agvService;
|
|
|
|
|
_airPorthttpClient = airPorthttpClient;
|
|
|
|
|
}
|
|
|
|
|
public static BaseStateRefreshBusiness GetInstance(ILogger<BaseStateRefreshBusiness> logger, IAGVStateService agvService, AirPorthttpClient airPorthttpClient)
|
|
|
|
|
{
|
|
|
|
|
if (instance == null)
|
|
|
|
|
{
|
|
|
|
|
instance = new BaseStateRefreshBusiness(logger, agvService, airPorthttpClient);
|
|
|
|
|
}
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 调用接口更新所有AGV的状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool UpdateALLAGVStateByResposne()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var response = _airPorthttpClient.AGVAllStateRequest();
|
|
|
|
|
if(response == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
_AGVStateService.UpdateOrAddByResponse(response);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("Error:" + e);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|