125 lines
4.2 KiB
C#
125 lines
4.2 KiB
C#
using System;
|
|
using SqlSugar;
|
|
using Infrastructure.Attribute;
|
|
using Infrastructure.Extensions;
|
|
using ZR.Model;
|
|
|
|
using ZR.Repository;
|
|
using ZR.Service.Business.IBusinessService;
|
|
using System.Linq;
|
|
using ZR.Model.MES.wms;
|
|
using ZR.Model.MES.wms.Dto;
|
|
using ZR.Service.mes.wms.IService;
|
|
using ZR.Model.MES.pro;
|
|
using Mapster;
|
|
|
|
namespace ZR.Service.Business
|
|
{
|
|
/// <summary>
|
|
/// 盘点记录Service业务层处理
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IWmAGVService), ServiceLifetime = LifeTime.Transient)]
|
|
public class WmAGVService : BaseService<AgvTask>, IWmAGVService
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
/// 1.获取工单列表
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public List<AGVWorkorderDto> GetList(QueryAGVparam param)
|
|
{
|
|
List<AGVWorkorderDto> aGVWorkorderDtos = new List<AGVWorkorderDto>();
|
|
var predicate = Expressionable.Create<ProWorkorder_v2>()
|
|
.AndIF(param.year > 0, it => it.Year == param.year)
|
|
.AndIF(param.week > 0, it => it.Week == param.week)
|
|
.AndIF(param.day > 0, it => it.Date == param.day);
|
|
|
|
var response = Context.Queryable<ProWorkorder_v2>()
|
|
.Where(it=>it.Remark3=="是")
|
|
.Where(predicate.ToExpression()).ToList();
|
|
foreach (var item in response)
|
|
{
|
|
aGVWorkorderDtos.Add(item.Adapt<AGVWorkorderDto>());
|
|
}
|
|
return aGVWorkorderDtos;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 2.获取当前工单下的所有AGV小车任务
|
|
/// </summary>
|
|
/// <param name="workorder_id"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public List<AgvTask> QueryAGVTask(string workorder_id)
|
|
{
|
|
return Context.Queryable<AgvTask>().Where(it => it.FkWorkorderId == workorder_id).OrderByDescending(it=>it.Sort).ToList();
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 3.新增AGV小车任务
|
|
/// </summary>
|
|
/// <param name="task"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public int AddAGVTask(AgvTask task)
|
|
{
|
|
int result = 0;
|
|
//TODO 1 判断agv小车task是否可以新增
|
|
if(string.IsNullOrEmpty(task.FkWorkorderId))
|
|
{
|
|
return -1;
|
|
}
|
|
ProWorkorder_v2 workorder = Context.Queryable<ProWorkorder_v2>()
|
|
.Where(it => it.Id == task.FkWorkorderId)
|
|
.First();
|
|
|
|
int require_num= workorder.PreviousNumber;
|
|
int all_require_num=Context.Queryable<AgvTask>().Where(it => it.FkWorkorderId == workorder.Id).Sum(it => it.Number)??0;
|
|
|
|
if(require_num>all_require_num)
|
|
{
|
|
task.Id = SnowFlakeSingle.Instance.NextId().ToString();
|
|
result= Context.Insertable(task).ExecuteCommand();
|
|
}
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 4.删除AGV小车任务
|
|
/// </summary>
|
|
/// <param name="taskId"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public int DeleteTask(string taskId)
|
|
{
|
|
return Context.Deleteable<AgvTask>().Where(it=>it.Id==taskId).ExecuteCommand();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 6 获取agv 起点和终点
|
|
/// </summary>
|
|
/// <param name="location"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public List<AgvLocation> GetAGV_position_list(AgvLocation location)
|
|
{
|
|
var predicate = Expressionable.Create<AgvLocation>()
|
|
.AndIF(location.AreaCode>-1, it => it.AreaCode == location.AreaCode)
|
|
.AndIF(location.Type > -1, it => it.Type == location.Type)
|
|
.AndIF(string.IsNullOrEmpty(location.Coordinate), it => it.Coordinate == location.Coordinate);
|
|
|
|
|
|
return Context.Queryable<AgvLocation>().Where(predicate.ToExpression()).ToList();
|
|
}
|
|
}
|
|
}
|