huangxiaoqiang
8 天以前 c3877b2ebec19f473f45e8c2245926f65d2a3948
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/AGVService.cs
@@ -33,8 +33,9 @@
        private readonly IMapper _mapper;
        private readonly IDt_DeviceInfoRepository _deviceInfoRepository;
        private readonly IDt_HandAutomaticRepository _handAutomaticRepository;
        private readonly IDt_ErrorDescriptionRepository _descriptionRepository;
        public AGVService(ILocationInfoRepository locationRepository, IDt_TaskRepository taskRepository, IDt_StationManagerRepository stationManagerRepository, IDt_DeviceInfoRepository deviceInfoRepository, IMapper mapper, SocketClientService socketClientService, IDt_TaskService taskService, IDt_HandAutomaticRepository handAutomaticRepository)
        public AGVService(ILocationInfoRepository locationRepository, IDt_TaskRepository taskRepository, IDt_StationManagerRepository stationManagerRepository, IDt_DeviceInfoRepository deviceInfoRepository, IMapper mapper, SocketClientService socketClientService, IDt_TaskService taskService, IDt_HandAutomaticRepository handAutomaticRepository, IDt_ErrorDescriptionRepository descriptionRepository)
        {
            _locationRepository = locationRepository;
            BaseDal = taskRepository;
@@ -44,6 +45,7 @@
            _Socket = socketClientService;
            _taskService = taskService;
            _handAutomaticRepository = handAutomaticRepository;
            _descriptionRepository = descriptionRepository;
        }
        #region å¤–部接口方法
@@ -58,7 +60,7 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                var location = _locationRepository.QueryData(x => x.LocationStatus==(int)LocationEnum.Free).ToList();
                var location = _locationRepository.QueryData(x => x.LocationStatus == (int)LocationEnum.Free).ToList();
                if (location.Count == 0)
                {
                    return content.Error("库内无可用库位");
@@ -492,7 +494,8 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                var task = BaseDal.QueryFirst(x => x.TaskNum ==Convert.ToInt32( aGVDTO.TaskNum));
                LogFactory.GetLog("AGV异常信息").InfoFormat(true, $"请求参数:{JsonConvert.SerializeObject(aGVDTO)}", "");
                var task = BaseDal.QueryFirst(x => x.TaskNum == Convert.ToInt32(aGVDTO.TaskNum));
                if (task != null)
                {
@@ -534,11 +537,11 @@
                        default: break;
                    }
                }
                LogFactory.GetLog("AGV异常信息").InfoFormat(true, $"请求参数:{JsonConvert.SerializeObject(aGVDTO)}", "");
                return content.OK();
            }
            catch (Exception ex)
            {
                LogFactory.GetLog("AGV异常信息").InfoFormat(true, $"请求参数:{JsonConvert.SerializeObject(ex.Message)}", "");
                return content.Error(ex.Message);
            }
        }
@@ -555,6 +558,44 @@
                return "";
            }
        }
        private static readonly SemaphoreSlim _semaphoreUpdate = new SemaphoreSlim(1, 1);
        public async Task<WebResponseContent> DeviceWarning(AGVDTO DTO)
        {
            await _semaphoreUpdate.WaitAsync();
            WebResponseContent content = new WebResponseContent();
            try
            {
                LogFactory.GetLog("AG上传报警信息").InfoFormat(true, $"请求参数:{JsonConvert.SerializeObject(DTO)}", "");
                if (DTO.Message != null)
                {
                    Dt_ErrorDescription description = _descriptionRepository.QueryFirst(x => x.Type == DTO.Message);
                    if (description != null)
                    {
                        _Socket.ErrorReport(description.ErrorCode, "A", "00");
                        _Socket.AddErrorMessage(description.ErrorCode, "AGV", "");
                        return content.OK();
                    }
                    else
                    {
                        return content.Error("未识别报警源");
                    }
                }
                else
                {
                    return content.Error("未接收到异常信息");
                }
            }
            catch (Exception ex)
            {
                LogFactory.GetLog("AG上传报警信息").InfoFormat(true, $"请求参数:{JsonConvert.SerializeObject(ex.Message)}", "");
                return content.Error(ex.Message);
            }
            finally
            {
                _semaphoreUpdate.Release();
            }
        }
        #endregion å¤–部接口方法
    }
}