131 lines
4.0 KiB
C#
131 lines
4.0 KiB
C#
using Infrastructure.Attribute;
|
|
using SqlSugar;
|
|
using System.Linq;
|
|
using ZR.Model;
|
|
using ZR.Model.Dto;
|
|
using ZR.Model.MES.mm;
|
|
using ZR.Repository;
|
|
using ZR.Service.mes.mm.IService;
|
|
|
|
namespace ZR.Service.Business
|
|
{
|
|
/// <summary>
|
|
/// agv位置表Service业务层处理
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IMmAgvLocationService), ServiceLifetime = LifeTime.Transient)]
|
|
public class MmAgvLocationService : BaseService<MmAgvLocation>, IMmAgvLocationService
|
|
{
|
|
/// <summary>
|
|
/// 查询agv位置表列表
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public PagedInfo<MmAgvLocationDto> GetList(MmAgvLocationQueryDto parm)
|
|
{
|
|
var predicate = Expressionable.Create<MmAgvLocation>()
|
|
.AndIF(parm.areaCode != 0, it => it.AreaCode == parm.areaCode);
|
|
|
|
var response = Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.ToPage<MmAgvLocation, MmAgvLocationDto>(parm);
|
|
|
|
return response;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取详情
|
|
/// </summary>
|
|
/// <param name="Id"></param>
|
|
/// <returns></returns>
|
|
public MmAgvLocation GetInfo(int Id)
|
|
{
|
|
var response = Queryable()
|
|
.Where(x => x.Id == Id)
|
|
.First();
|
|
|
|
return response;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加agv位置表
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public MmAgvLocation AddMmAgvLocation(MmAgvLocation model)
|
|
{
|
|
return Context.Insertable(model).ExecuteReturnEntity();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改agv位置表
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public int UpdateMmAgvLocation(MmAgvLocation model)
|
|
{
|
|
//var response = Update(w => w.Id == model.Id, it => new MmAgvLocation()
|
|
//{
|
|
// AreaCode = model.AreaCode,
|
|
// Area = model.Area,
|
|
// Type = model.Type,
|
|
// Coordinate = model.Coordinate,
|
|
// Status = model.Status,
|
|
// CreatedBy = model.CreatedBy,
|
|
// CreatedTime = model.CreatedTime,
|
|
// UpdatedBy = model.UpdatedBy,
|
|
// UpdatedTime = model.UpdatedTime,
|
|
//});
|
|
//return response;
|
|
return Update(model, true);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取地域选择
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<(int, string)> ListAreaOptions()
|
|
{
|
|
// 使用 LINQ 查询获取结果
|
|
var queryResult = Context.Queryable<MmAgvLocation>()
|
|
.GroupBy(it => it.AreaCode)
|
|
.Select(it => new
|
|
{
|
|
item1 = it.AreaCode, // 使用 Key 获取分组的键值
|
|
item2 = SqlFunc.AggregateMax(it.Area), // 聚合 Area 字段的最大值
|
|
})
|
|
.ToList();
|
|
|
|
// 将匿名对象转换为 List<(int, string)>
|
|
List<(int, string)> lists = queryResult
|
|
.Select(item => ((int)item.item1, item.item2))
|
|
.ToList();
|
|
|
|
|
|
|
|
return lists;
|
|
}
|
|
/// <summary>
|
|
/// 更改状态
|
|
/// </summary>
|
|
/// <param name="index"></param>
|
|
/// <param name="status"></param>
|
|
/// <returns></returns>
|
|
public int Updatestatus(int index, int status)
|
|
{
|
|
return Context.Updateable<MmAgvLocation>().Where(it => it.Id == index).SetColumns(it => it.Status == status).ExecuteCommand();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询agv状态
|
|
/// </summary>
|
|
/// <param name="agvCode"></param>
|
|
/// <returns></returns>
|
|
public AGVstatus CallagvStatus(int agvCode)
|
|
{
|
|
string url = "";
|
|
return AGVstatus.下放重试失败;
|
|
}
|
|
}
|
|
} |