1231234
This commit is contained in:
@@ -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