wms:agv:init
This commit is contained in:
130
ZR.Admin.WebApi/Controllers/mes/wms/WmAGVController.cs
Normal file
130
ZR.Admin.WebApi/Controllers/mes/wms/WmAGVController.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
using ZR.Service.Business;
|
||||
using ZR.Service.Business.IBusinessService;
|
||||
using ZR.Service.mes.wms;
|
||||
using ZR.Service.mes.wms.IService;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// agv 相关接口
|
||||
/// </summary>
|
||||
|
||||
[Route("/mes/wm/agv")]
|
||||
public class WmAGVController : BaseController
|
||||
{
|
||||
private readonly IWmAGVService _WmAGVService;
|
||||
public WmAGVController(IWmAGVService wmAGVService)
|
||||
{
|
||||
_WmAGVService = wmAGVService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 1. 获取工单
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpGet("get_workorder_list")]
|
||||
public IActionResult QueryWmAGV_list([FromQuery] QueryAGVparam parm)
|
||||
{
|
||||
if(parm == null)
|
||||
{
|
||||
return SUCCESS(null);
|
||||
}
|
||||
var response = _WmAGVService.GetList(parm);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 2.获取当前工单下的所有AGV小车任务
|
||||
/// </summary>
|
||||
/// <param name="workorder_id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetTask")]
|
||||
public IActionResult QueryAGVTask(string workorder_id)
|
||||
{
|
||||
if(string.IsNullOrEmpty(workorder_id))
|
||||
{
|
||||
return SUCCESS(null);
|
||||
}
|
||||
|
||||
var response= _WmAGVService.QueryAGVTask(workorder_id);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 3.新增agv小车任务
|
||||
/// </summary>
|
||||
/// <param name="task"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("add_task")]
|
||||
public IActionResult AddAGVTask(AgvTask task)
|
||||
{
|
||||
string msg = null;
|
||||
if(task == null)
|
||||
{
|
||||
|
||||
return SUCCESS(null);
|
||||
}
|
||||
task.ToCreate();
|
||||
int result= _WmAGVService.AddAGVTask(task);
|
||||
if(result == 0)
|
||||
{
|
||||
msg = "插入失败";
|
||||
}else if(result == 1)
|
||||
{
|
||||
msg = "新增成功";
|
||||
}
|
||||
else if (result == -1)
|
||||
{
|
||||
msg = "工单号为空";
|
||||
}
|
||||
return ToResponse(new ApiResult(200, msg, result));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 4.删除AGV小车任务
|
||||
/// </summary>
|
||||
/// <param name="taskId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("deleteTask")]
|
||||
public IActionResult DeleteTask(string taskId)
|
||||
{
|
||||
|
||||
if(string.IsNullOrEmpty(taskId))
|
||||
{
|
||||
return SUCCESS(null);
|
||||
}
|
||||
|
||||
int data = _WmAGVService.DeleteTask(taskId);
|
||||
return SUCCESS(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 5. 获取agv位置
|
||||
/// </summary>
|
||||
/// <param name="taskId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("get_agv_position")]
|
||||
public IActionResult GetAGV_position_list(AgvLocation location)
|
||||
{
|
||||
if(location == null)
|
||||
{
|
||||
return SUCCESS(null);
|
||||
}
|
||||
var response= _WmAGVService.GetAGV_position_list(location);
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
88
ZR.Model/MES/wms/Dto/AGVtaskDto.cs
Normal file
88
ZR.Model/MES/wms/Dto/AGVtaskDto.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using MiniExcelLibs.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZR.Model.MES.wms.Dto
|
||||
{
|
||||
|
||||
public class QueryAGVPosition
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public class AGVtaskDto
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询参数
|
||||
/// </summary>
|
||||
public class QueryAGVparam
|
||||
{
|
||||
public int year { get; set; }
|
||||
public int week { get; set; }
|
||||
public int day { get; set; }
|
||||
public int status { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 工单
|
||||
/// </summary>
|
||||
public class AGVWorkorderDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 工单id(内部)
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户工单号
|
||||
/// </summary>
|
||||
public string ClientWorkorder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 毛坯号
|
||||
/// </summary>
|
||||
public string BlankNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品描述
|
||||
/// </summary>
|
||||
public string ProductDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 颜色
|
||||
/// </summary>
|
||||
public string Colour { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 规格
|
||||
/// </summary>
|
||||
public string Specifications { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码号
|
||||
/// </summary>
|
||||
public int CodeNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上件总数
|
||||
/// </summary>
|
||||
public int PreviousNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 未上件数
|
||||
/// </summary>
|
||||
public int NoPreviousNumber { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
23
ZR.Service/mes/wms/IService/IWmAGVService.cs
Normal file
23
ZR.Service/mes/wms/IService/IWmAGVService.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using ZR.Model;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
namespace ZR.Service.mes.wms.IService
|
||||
{
|
||||
public interface IWmAGVService
|
||||
{
|
||||
|
||||
List<AGVWorkorderDto> GetList(QueryAGVparam param);
|
||||
|
||||
|
||||
List<AgvTask> QueryAGVTask(string workorder_id);
|
||||
|
||||
int AddAGVTask(AgvTask task);
|
||||
|
||||
int DeleteTask(string taskId);
|
||||
|
||||
List<AgvLocation> GetAGV_position_list(AgvLocation location);
|
||||
}
|
||||
}
|
||||
124
ZR.Service/mes/wms/WmAGVService.cs
Normal file
124
ZR.Service/mes/wms/WmAGVService.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
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(string.IsNullOrEmpty(location.Area), it => it.Area == location.Area)
|
||||
.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user