generated from wenjy/SlnMesnac
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
3.2 KiB
C#
117 lines
3.2 KiB
C#
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<AGVSetting>, IAGVSettingService
|
|
{
|
|
private ILogger<AGVSettingServiceImpl> _logger;
|
|
public AGVSettingServiceImpl(Repository<AGVSetting> repository, ILogger<AGVSettingServiceImpl> logger) : base(repository)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取所有AGV设置
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<AGVSetting> GetAllAgvSetting()
|
|
{
|
|
List<AGVSetting> agvSettingList = new List<AGVSetting>();
|
|
try
|
|
{
|
|
agvSettingList = _rep.GetList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError($"所有AGV设置获取错误:{ex.Message}");
|
|
}
|
|
return agvSettingList;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据AgvGuid获取单条AGV设置
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
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();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 根据AGVID获取AGV类型
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
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 "";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 插入AGV设置
|
|
/// </summary>
|
|
/// <param name="agvSetting"></param>
|
|
/// <returns></returns>
|
|
public bool InsertAgvSetting(AGVSetting agvSetting)
|
|
{
|
|
try
|
|
{
|
|
return _rep.Insert(agvSetting);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
_logger.LogError("插入新的AGV设置异常" + ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据ID删除AGV设置
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public bool DeleteAgvSettingByID(int id)
|
|
{
|
|
try
|
|
{
|
|
return _rep.DeleteById(id);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError("插入新的AGV设置");
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|