using Microsoft.Extensions.Logging; using SlnMesnac.Model.domain; using SlnMesnac.Repository.service.@base; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SlnMesnac.Repository.service.Impl { public class AGVSettingServiceImpl : BaseServiceImpl, IAGVSettingService { private ILogger _logger; public AGVSettingServiceImpl(Repository repository, ILogger logger) : base(repository) { _logger = logger; } /// /// 获取所有AGV设置 /// /// public List GetAllAgvSetting() { List agvSettingList = new List(); try { agvSettingList = _rep.GetList(); } catch (Exception ex) { _logger.LogError($"所有AGV设置获取错误:{ex.Message}"); } return agvSettingList; } /// /// 根据AgvGuid获取单条AGV设置 /// /// public AGVSetting GetAgvSettingByAgvGuid(string guid) { try { var res = _rep.GetList(x => x.AGVNo == guid).FirstOrDefault(); if(res == null) { return new AGVSetting(); } return res; } catch (Exception ex) { _logger.LogError("根据AGVID获取AGV类型异常" + ex.Message); return new AGVSetting(); } } /// /// 根据AGVID获取AGV类型 /// /// /// public string GetAgvTypeByAGVGuid(string guid) { try { var res = _rep.GetList(x => x.AGVNo == guid).FirstOrDefault().AGVType; return res; } catch(Exception ex) { _logger.LogError("根据AGVID获取AGV类型异常" + ex.Message); return ""; } } /// /// 插入AGV设置 /// /// /// public bool InsertAgvSetting(AGVSetting agvSetting) { try { return _rep.Insert(agvSetting); } catch(Exception ex) { _logger.LogError("插入新的AGV设置异常" + ex.Message); return false; } } /// /// 根据ID删除AGV设置 /// /// /// public bool DeleteAgvSettingByID(int id) { try { return _rep.DeleteById(id); } catch (Exception ex) { _logger.LogError("插入新的AGV设置"); return false; } } } }