|
|
|
@ -1,31 +1,35 @@
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using SlnMesnac.Model.AirportApiEntity;
|
|
|
|
|
using SlnMesnac.Repository;
|
|
|
|
|
using SlnMesnac.Repository.service;
|
|
|
|
|
using SlnMesnac.TouchSocket;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SlnMesnac.Business.@base
|
|
|
|
|
{
|
|
|
|
|
public class BaseStateRefreshBusiness
|
|
|
|
|
{
|
|
|
|
|
private IAGVStateService _AGVStateService;
|
|
|
|
|
private IAGVSettingService _aGVSettingService;
|
|
|
|
|
private ILogger<BaseStateRefreshBusiness> _logger;
|
|
|
|
|
private static BaseStateRefreshBusiness instance;
|
|
|
|
|
private AirPorthttpClient _airPorthttpClient;
|
|
|
|
|
|
|
|
|
|
public BaseStateRefreshBusiness(ILogger<BaseStateRefreshBusiness> logger, IAGVStateService agvService, AirPorthttpClient airPorthttpClient)
|
|
|
|
|
public BaseStateRefreshBusiness(ILogger<BaseStateRefreshBusiness> logger, IAGVStateService agvService, AirPorthttpClient airPorthttpClient, IAGVSettingService aGVSettingService)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_AGVStateService = agvService;
|
|
|
|
|
_airPorthttpClient = airPorthttpClient;
|
|
|
|
|
_aGVSettingService = aGVSettingService;
|
|
|
|
|
}
|
|
|
|
|
public static BaseStateRefreshBusiness GetInstance(ILogger<BaseStateRefreshBusiness> logger, IAGVStateService agvService, AirPorthttpClient airPorthttpClient)
|
|
|
|
|
public static BaseStateRefreshBusiness GetInstance(ILogger<BaseStateRefreshBusiness> logger, IAGVStateService agvService, AirPorthttpClient airPorthttpClient, IAGVSettingService aGVSettingService)
|
|
|
|
|
{
|
|
|
|
|
if (instance == null)
|
|
|
|
|
{
|
|
|
|
|
instance = new BaseStateRefreshBusiness(logger, agvService, airPorthttpClient);
|
|
|
|
|
instance = new BaseStateRefreshBusiness(logger, agvService, airPorthttpClient, aGVSettingService);
|
|
|
|
|
}
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
@ -34,7 +38,7 @@ namespace SlnMesnac.Business.@base
|
|
|
|
|
/// 调用接口更新所有AGV的状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool UpdateALLAGVStateByResposne()
|
|
|
|
|
public async Task<bool> UpdateALLAGVStateByResposne()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -43,14 +47,28 @@ namespace SlnMesnac.Business.@base
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
_AGVStateService.UpdateOrAddByResponse(response);
|
|
|
|
|
|
|
|
|
|
List<AGVState> records = new List<AGVState>();
|
|
|
|
|
foreach (var entity in response.Data)
|
|
|
|
|
{
|
|
|
|
|
AGVState record = new AGVState()
|
|
|
|
|
{
|
|
|
|
|
agvno = entity.Guid,
|
|
|
|
|
agvalarmstate = entity.AgvMoveStatus != 6 ? "正常" : "异常",
|
|
|
|
|
agvtype = _aGVSettingService.GetAgvSettingByID(entity.Guid),
|
|
|
|
|
agvworkstate = entity.AgvMoveStatus == 1 ? "空闲" : "忙碌",
|
|
|
|
|
refreshtime = DateTime.Now,
|
|
|
|
|
taskno = entity.TaskID,
|
|
|
|
|
};
|
|
|
|
|
records.Add(record);
|
|
|
|
|
}
|
|
|
|
|
return await _AGVStateService.UpdateOrAddRecords(records);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("Error:" + e);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|