1231234
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.ComponentModel;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model.MES.wms;
|
||||
@@ -126,5 +127,42 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 7 生成 agv 任务号
|
||||
/// </summary>
|
||||
/// <param name="taskid"></param>
|
||||
/// <param name="flag">1 是去 2 是回车</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("generate_agv_task")]
|
||||
[Log(Title = "AGV调度")]
|
||||
public IActionResult GenerateAgvTask(string taskid,int flag)
|
||||
{
|
||||
string msg = "任务调度成功";
|
||||
if(string.IsNullOrEmpty(taskid))
|
||||
{
|
||||
|
||||
return SUCCESS(null);
|
||||
}
|
||||
|
||||
string status = _WmAGVService.GenerateAgvTask(taskid,flag);
|
||||
|
||||
return ToResponse(new ApiResult(200, msg, status));
|
||||
}
|
||||
|
||||
// cancelTask
|
||||
[HttpGet("cancel_agv_task")]
|
||||
public IActionResult CancelAGVTask(string taskId, int flag)
|
||||
{
|
||||
string msg = "取消任务成功";
|
||||
if(string.IsNullOrEmpty(taskId))
|
||||
{
|
||||
return SUCCESS(null);
|
||||
}
|
||||
|
||||
string status = _WmAGVService.CancelAGVTask(taskId, flag);
|
||||
return ToResponse(new ApiResult(200, msg, status));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,6 +167,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
|
||||
return SUCCESS(WmOutOrderPlanList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 5 成品出库
|
||||
/// </summary>
|
||||
|
||||
54
ZR.Model/MES/wms/AGVtask_third.cs
Normal file
54
ZR.Model/MES/wms/AGVtask_third.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZR.Model.MES.wms
|
||||
{
|
||||
/// <summary>
|
||||
/// 对接agv 第三方
|
||||
/// </summary>
|
||||
public class AGVtask_third
|
||||
{
|
||||
public string reqCode { get; set; }
|
||||
public string msg { get; set; }
|
||||
|
||||
public List<AGV_location_third> positionCodePath { get; set; }
|
||||
}
|
||||
public class AGV_location_third
|
||||
{
|
||||
public string positionCode { get; set; }
|
||||
public string type { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成任务单 第三方 返回值
|
||||
/// </summary>
|
||||
public class AGV_task_third
|
||||
{
|
||||
|
||||
public string code { get; set;}
|
||||
|
||||
public string message { get; set;}
|
||||
|
||||
public string reqCode { get;set;}
|
||||
|
||||
public string data { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// agv 取消任务
|
||||
/// </summary>
|
||||
public class AGVtask_cancel_third
|
||||
{
|
||||
public string reqCode { get; set;}
|
||||
public string forceCancel { get; set;}
|
||||
public string taskCode { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -40,6 +40,16 @@ namespace ZR.Model.MES.wms
|
||||
[SugarColumn(ColumnName = "go_end_point")]
|
||||
public string GoEndPoint { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 启程
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(ColumnName = "go_task_id")]
|
||||
public string GoTaskId { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
@@ -57,6 +67,12 @@ namespace ZR.Model.MES.wms
|
||||
[SugarColumn(ColumnName = "back_end_point")]
|
||||
public string BackEndPoint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 回程
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "back_task_id")]
|
||||
public string BackTaskId{ get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
|
||||
@@ -77,12 +77,5 @@ namespace ZR.Model.MES.wms.Dto
|
||||
/// 未上件数
|
||||
/// </summary>
|
||||
public int NoPreviousNumber { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,5 +19,8 @@ namespace ZR.Service.mes.wms.IService
|
||||
int DeleteTask(string taskId);
|
||||
|
||||
List<AgvLocation> GetAGV_position_list(AgvLocation location);
|
||||
|
||||
string GenerateAgvTask(string taskid,int flag);
|
||||
string CancelAGVTask(string taskId, int flag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ using ZR.Model.MES.wms.Dto;
|
||||
using ZR.Service.mes.wms.IService;
|
||||
using ZR.Model.MES.pro;
|
||||
using Mapster;
|
||||
using Infrastructure;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZR.Service.Business
|
||||
{
|
||||
@@ -21,7 +24,7 @@ namespace ZR.Service.Business
|
||||
[AppService(ServiceType = typeof(IWmAGVService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class WmAGVService : BaseService<AgvTask>, IWmAGVService
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 1.获取工单列表
|
||||
@@ -30,14 +33,14 @@ namespace ZR.Service.Business
|
||||
/// <returns></returns>
|
||||
public List<AGVWorkorderDto> GetList(QueryAGVparam param)
|
||||
{
|
||||
List<AGVWorkorderDto> aGVWorkorderDtos = new List<AGVWorkorderDto>();
|
||||
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(it => it.Remark3 == "是")
|
||||
.Where(predicate.ToExpression()).ToList();
|
||||
foreach (var item in response)
|
||||
{
|
||||
@@ -55,7 +58,7 @@ namespace ZR.Service.Business
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public List<AgvTask> QueryAGVTask(string workorder_id)
|
||||
{
|
||||
return Context.Queryable<AgvTask>().Where(it => it.FkWorkorderId == workorder_id).OrderBy(it=>it.Sort).ToList();
|
||||
return Context.Queryable<AgvTask>().Where(it => it.FkWorkorderId == workorder_id).OrderBy(it => it.Sort).ToList();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,21 +73,21 @@ namespace ZR.Service.Business
|
||||
{
|
||||
int result = 0;
|
||||
//TODO 1 判断agv小车task是否可以新增
|
||||
if(string.IsNullOrEmpty(task.FkWorkorderId))
|
||||
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)
|
||||
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();
|
||||
result = Context.Insertable(task).ExecuteCommand();
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +103,7 @@ namespace ZR.Service.Business
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public int DeleteTask(string taskId)
|
||||
{
|
||||
return Context.Deleteable<AgvTask>().Where(it=>it.Id==taskId).ExecuteCommand();
|
||||
return Context.Deleteable<AgvTask>().Where(it => it.Id == taskId).ExecuteCommand();
|
||||
|
||||
}
|
||||
|
||||
@@ -113,12 +116,123 @@ namespace ZR.Service.Business
|
||||
public List<AgvLocation> GetAGV_position_list(AgvLocation location)
|
||||
{
|
||||
var predicate = Expressionable.Create<AgvLocation>()
|
||||
.AndIF(location.AreaCode>-1, it => it.AreaCode == location.AreaCode)
|
||||
.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();
|
||||
return Context.Queryable<AgvLocation>().Where(predicate.ToExpression()).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 7 生成agv任务
|
||||
/// </summary>
|
||||
/// <param name="taskid"></param>
|
||||
/// <returns></returns>
|
||||
public string GenerateAgvTask(string taskid,int flag)
|
||||
{
|
||||
AgvTask agvTask= Context.Queryable<AgvTask>().Where(it => it.Id == taskid).First();
|
||||
string url = "http://192.168.60.1:443/rcms/services/rest/hikRpcService/genAgvSchedulingTask";
|
||||
string start_point = "";
|
||||
string end_point = "";
|
||||
|
||||
if (flag==1) {
|
||||
start_point =agvTask.GoStartPoint;
|
||||
end_point = agvTask.GoEndPoint;
|
||||
}
|
||||
else if (flag==2)
|
||||
{
|
||||
start_point = agvTask.BackStartPoint;
|
||||
end_point = agvTask.BackEndPoint;
|
||||
|
||||
}
|
||||
AGVtask_third task = new AGVtask_third();
|
||||
task.reqCode = taskid;
|
||||
task.positionCodePath = new List<AGV_location_third>
|
||||
{
|
||||
new AGV_location_third()
|
||||
{
|
||||
positionCode=start_point,
|
||||
type="00"
|
||||
|
||||
},
|
||||
new AGV_location_third()
|
||||
{
|
||||
positionCode=end_point,
|
||||
type="01"
|
||||
|
||||
}
|
||||
};
|
||||
string postData = JsonSerializer.Serialize(task);
|
||||
|
||||
|
||||
|
||||
string response= HttpHelper.HttpPost(url, postData);
|
||||
|
||||
|
||||
|
||||
AGV_task_third res_data= JsonSerializer.Deserialize<AGV_task_third>(response);
|
||||
|
||||
if(res_data!=null &&res_data.code=="0") {
|
||||
|
||||
if (flag == 1)
|
||||
{
|
||||
Context.Updateable<AgvTask>().SetColumns(it => it.GoTaskId == res_data.reqCode)
|
||||
.Where(it => it.Id == agvTask.Id).ExecuteCommand();
|
||||
}
|
||||
else if (flag == 2)
|
||||
{
|
||||
Context.Updateable<AgvTask>().SetColumns(it => it.BackTaskId == res_data.reqCode)
|
||||
.Where(it => it.Id == agvTask.Id).ExecuteCommand();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 8.取消agv任务
|
||||
/// </summary>
|
||||
/// <param name="taskId"></param>
|
||||
/// <param name="flag"></param>
|
||||
public string CancelAGVTask(string taskId, int flag)
|
||||
{
|
||||
if(flag!=1||flag!=2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
AgvTask agvTask = Context.Queryable<AgvTask>().Where(it => it.Id == taskId).First();
|
||||
if(agvTask!=null)
|
||||
{
|
||||
string task_id = null;
|
||||
if (flag == 1)
|
||||
{
|
||||
//
|
||||
task_id = agvTask.GoTaskId;
|
||||
}else if (flag == 2)
|
||||
{
|
||||
task_id = agvTask.BackTaskId;
|
||||
}
|
||||
|
||||
string url = "http://192.168.60.1:443/rcms/services/rest/hikRpcService/cancelTask";
|
||||
AGVtask_cancel_third req = new AGVtask_cancel_third();
|
||||
req.reqCode = taskId;
|
||||
req.forceCancel = "1";
|
||||
req.taskCode = task_id;
|
||||
string postData= JsonSerializer.Serialize(req);
|
||||
|
||||
|
||||
|
||||
|
||||
string response = HttpHelper.HttpPost(url, postData);
|
||||
|
||||
return response;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user